I did the second example in the Quick Start section of the documentation (An agent with a behaviour). It is stated, that "this agent would go on counting forever until we press ctrl+C.".
But if I press Ctrl+C, the agent won't stop. It says "Keyboard interrupt received. Stopping SPADE..." but continues.
What I Did
import asyncio
import spade
from spade import wait_until_finished
from spade.agent import Agent
from spade.behaviour import CyclicBehaviour
class DummyAgent(Agent):
class MyBehav(CyclicBehaviour):
async def on_start(self):
print("Starting behaviour . . .")
self.counter = 0
async def run(self):
print("Counter: {}".format(self.counter))
self.counter += 1
await asyncio.sleep(1)
async def setup(self):
print("Agent starting . . .")
b = self.MyBehav()
self.add_behaviour(b)
async def main():
dummy = DummyAgent("???", "???")
await dummy.start()
print("DummyAgent started. Check its console to see the output.")
print("Wait until user interrupts with ctrl+C")
await wait_until_finished(dummy)
if __name__ == "__main__":
spade.run(main())
Output:
Agent starting . . .
DummyAgent started. Check its console to see the output.
Wait until user interrupts with ctrl+C
Starting behaviour . . .
Counter: 0
Counter: 1
Counter: 2
Counter: 3
Counter: 4
Keyboard interrupt received. Stopping SPADE...
Counter: 5
Counter: 6
Counter: 7
Counter: 8
Counter: 9
...
Description
I did the second example in the Quick Start section of the documentation (An agent with a behaviour). It is stated, that "this agent would go on counting forever until we press ctrl+C.". But if I press Ctrl+C, the agent won't stop. It says "Keyboard interrupt received. Stopping SPADE..." but continues.
What I Did
Output: