PR #316 · pramaan-io/pramaan-functions · merged 2026-06-12
One container, one async world — or none at all.
Bug twelve-twenty-nine
Every connection lives in its own async world — they cannot coordinate.
The fix — One container, one loop — every WS connection shares the same async world.
sequenceDiagram autonumber participant container as Container participant handler as WS Handler participant connections as WS Clients container->>handler: container boots handler->>handler: first _event_loop() call handler->>handler: _persistent_loop created connections->>handler: client connects handler->>handler: _event_loop() returns same loop handler-->>connections: all pulse on one loop
| Method | in → out | what it does |
|---|---|---|
_event_loop | () → asyncio.AbstractEventLoop | returns the persistent loop, creating it once on the very first call |
src/app_api/router_ws.py+20 −1WebSocket router — adds a container-level singleton asyncio loop via the persistent-loop field and the event-loop getter, fixing Bug twelve-twenty-nine.
| new method | signature |
|---|---|
_event_loop | () → asyncio.AbstractEventLoop |
_persistent_loop : asyncio.AbstractEventLoop | None| File | ± |
|---|---|
src/app_api/router_ws.py ★ | +20 −1 |
tests/unit/test_router_ws.py | +11 |