lib.AsyncRunner: Fix asyncio.Event() for Python 3.12+ #61

Merged
Jan Lindemann merged 1 commit from jan/feature/20260815-lib-asyncrunner-fix-asyncio-event-for-python into master 2026-08-15 20:00:30 +02:00 AGit

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.

#### 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.
lib.AsyncRunner: Fix asyncio.Event() for Python 3.12+
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m33s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m15s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m2s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 3m53s
CI / Packaging test (push) Successful in 0s
ac35da6d9c
AsyncRunner is currently unused. This bug was detected and fixed by
AI.

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.

Assisted-by: unsloth/Qwen3.6-27B-MTP-GGUF:Q4_K_M with pi.dev v0.84.1
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-08-15 19:51:38 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!61
No description provided.