-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Blocking time.sleep() calls in async code paths stall the event loopΒ #1261
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
Multiple time.sleep() calls exist in code paths that execute inside the async event loop. This blocks the entire event loop, preventing all other agents/tasks from making progress.
Principle violated: "Performance-first", "Async-safe by default"
Critical Locations in praisonaiagents/agent/execution_mixin.py
| Line | Call | Context |
|---|---|---|
| 956 | time.sleep(0.5) |
After server start |
| 959 | time.sleep(0.1) |
Server wait polling loop |
| 988 | time.sleep(1) |
In loop() |
| 997 | time.sleep(1) |
In loop() |
| 1056 | time.sleep(0.5) |
After thread start |
| 1061 | time.sleep(1) |
In loop() |
Impact
When running multiple agents concurrently via asyncio, a single time.sleep(1) freezes ALL agents for 1 second. The event loop cannot service any other coroutines during blocking sleep calls. In a 10-agent workflow with sequential sleeps, this compounds to seconds of wasted wall-clock time per iteration cycle.
Suggested Fix
- Replace
time.sleep()withawait asyncio.sleep()in async contexts - For sync/async dual code paths, detect the running loop and dispatch accordingly
- Server readiness should use
asyncio.Eventsignaling instead of polling with sleep
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working