Git Product home page Git Product logo

Comments (4)

javipalanca avatar javipalanca commented on May 8, 2024

Hi.
This is because the SPADE core is still running in the process, waiting for more agents.
I've implemented a quit_spade function that unfortunately isn't still in the docs.
Try:

from spade import agent
from spade import quit_spade

class DummyAgent(agent.Agent):
    async def setup(self):
        print("Hello World! I'm agent{}".format(str(self.jid)))

dummy = DummyAgent("your_jid@your_xmpp_server", "your_password")

dummy.start()

dummy.stop()

quit_spade()

from spade.

ErtHub avatar ErtHub commented on May 8, 2024

Hi.
Thank you for turning your attention to my issue. I have tried running the code you suggested, however I get as a result a different type of error now:

C:\Users\jatko\AppData\Local\Programs\Python\Python37-32\lib\site-packages\spade\container.py:136: RuntimeWarning: coroutine 'wait_for' was never awaited
  asyncio.wait_for(future, timeout=5)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Task was destroyed but it is pending!
task: <Task pending coro=<Agent._async_start() running at C:\Users\jatko\AppData\Local\Programs\Python\Python37-32\lib\site-packages\spade\agent.py:86> cb=[_chain_future.<locals>._call_set_state() at C:\Users\jatko\AppData\Local\Programs\Python\Python37-32\lib\asyncio\futures.py:355]>
Task was destroyed but it is pending!
task: <Task pending coro=<Agent._async_stop() running at C:\Users\jatko\AppData\Local\Programs\Python\Python37-32\lib\site-packages\spade\agent.py:254> cb=[_chain_future.<locals>._call_set_state() at C:\Users\jatko\AppData\Local\Programs\Python\Python37-32\lib\asyncio\futures.py:355]>
sys:1: RuntimeWarning: coroutine 'Agent._async_start' was never awaited
sys:1: RuntimeWarning: coroutine 'Agent._async_stop' was never awaited

It appears to me that dummy.start() and dummy.stop() calls should be preceded with an await command, however I can't seem to figure out how to do it properly. Is there anything else I'm not doing right?

from spade.

javipalanca avatar javipalanca commented on May 8, 2024

Take a look at the documentation about that: https://spade-mas.readthedocs.io/en/latest/usage.html#creating-an-agent-from-within-another-agent

start and stop are used differently from inside a coroutine and from outside.
Basically, if you call start or stop in a coroutine you must await it. Otherwise not.

from spade.

javipalanca avatar javipalanca commented on May 8, 2024

By the way, at SPADE 3.1.2 the bug of quit_spade was fixed. So, please ensure you are upgraded :)

from spade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.