lib.AsyncRunner: Fix asyncio.Event() for Python 3.12+ #61
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/feature/20260815-lib-asyncrunner-fix-asyncio-event-for-python"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
lib.AsyncRunner: Fix asyncio.Event() for Python 3.12+
AsyncRunner is currently unused, so this doesn't fix a known behavioural issue. The bug was detected and fixed during AI code analysis instead:
asyncio.Event() raises RuntimeError on Python 3.12+ when created outside a running event loop. It is created in the sync portion of loop_in_thread(), before the threaded loop is up.
The fix is to move the Event creation inside the async main() coroutine and pass it back via a second future. It replaces the fragile as_completed loop with sequential result() calls, so failures are immediately visible rather than causing a silent thread hang.