pkg.lib.App: Fix event loop for Python 3.14+ #59
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/feature/20260814-pkg-lib-app-fix-event-loop-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?
pkg.lib.App: Fix event loop for Python 3.14+
asyncio.get_event_loop() is removed in Python 3.14 when called from outside an async context. The current code calls it in init(), which crashes on 3.14+.
To fix this, drop the eager loop creation from init(). Instead, lazily create a loop in run() via asyncio.new_event_loop() when no external loop was provided, and close it in the finally block. This makes the lifecycle symmetric: run() owns the full create-use-close cycle and supports re-entrant calls.
Replace del() with an explicit close() method, guarding against double-close via is_closed(). close() always clears __eloop to None so a closed loop never lingers.