javipalanca / spade

Smart Python Agent Development Environment
MIT License
258 stars 98 forks source link

The loop parameter to Queue is deprecated/removed #103

Closed cedricbonhomme closed 1 year ago

cedricbonhomme commented 2 years ago

Description

The loop parameter to Queue is deprecated/removed

$ python pumpkin/correlation.py 
Agent starting . . .
Traceback (most recent call last):
  File "/home/cedric/git/pumpkin/pumpkin/correlation.py", line 27, in <module>
    future.result()
  File "/home/cedric/.pyenv/versions/3.11.0/lib/python3.11/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/cedric/.pyenv/versions/3.11.0/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/cedric/.local/share/hatch/env/virtual/pumpkin/bXdZuwLV/pumpkin/lib/python3.11/site-packages/spade/agent.py", line 137, in _async_start
    await self.setup()
  File "/home/cedric/git/pumpkin/pumpkin/correlation.py", line 21, in setup
    self.add_behaviour(b)
  File "/home/cedric/.local/share/hatch/env/virtual/pumpkin/bXdZuwLV/pumpkin/lib/python3.11/site-packages/spade/agent.py", line 251, in add_behaviour
    behaviour.set_agent(agent=self)
  File "/home/cedric/.local/share/hatch/env/virtual/pumpkin/bXdZuwLV/pumpkin/lib/python3.11/site-packages/spade/behaviour.py", line 63, in set_agent
    self.queue = asyncio.Queue(loop=self.agent.loop)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Queue.__init__() got an unexpected keyword argument 'loop'

Simply removing the use of the argument loop in spade/behaviour.py (line 63) fixed the issue.

Tested with Python 3.10 and 3.11. From the documentation here:

Application developers should typically use the high-level asyncio functions, such as asyncio.run(), and should rarely need to reference the loop object or call its methods. This section is intended mostly for authors of lower-level code, libraries, and frameworks, who need finer control over the event loop behavior.

It is no more needed to pass the global event loop.

Do you plan to fix this `soonish`` ? Else I must try with Python 3.8. or 3.9.

Thank you.

cedricbonhomme commented 2 years ago

I just noticed that the PR #102 is solving this issue, for your information.

gciatto commented 1 year ago

Any ETA on this?

0x1F602 commented 1 year ago

@cedricbonhomme @gciatto I've successfully used python 3.9 on the develop branch of this repo. @javipalanca updated the docs on the develop branch and I can confirm it works for me.

javipalanca commented 1 year ago

Hi. SPADE 3.3 has fixed the compatibility with python 3.9 and 3.10. Please upgrade.