fix: fix test race condition

ref: N25B-301
This commit is contained in:
2025-11-25 11:21:25 +01:00
parent ef00c03ec5
commit e5949a7273
9 changed files with 25 additions and 58 deletions

View File

@@ -33,14 +33,16 @@ async def test_agent_lifecycle():
# Test background task
async def dummy_task():
await asyncio.sleep(0.01)
pass
await agent.add_behavior(dummy_task())
assert len(agent._tasks) > 0
task = agent.add_behavior(dummy_task())
assert task in agent._tasks
await task
# Wait for task to finish
await asyncio.sleep(0.02)
assert len(agent._tasks) == 2 # message handling tasks are running
assert task not in agent._tasks
assert len(agent._tasks) == 2 # message handling tasks are still running
await agent.stop()
assert agent._running is False