Skip to content

Fix AppService init crash on Python 3.14 without a preset event loop (#3368) - #3430

Open
hakarrr wants to merge 2 commits into
apache:masterfrom
hakarrr:fix/appsvc-eventloop-py314
Open

hakarrr wants to merge 2 commits into
apache:masterfrom
hakarrr:fix/appsvc-eventloop-py314

Conversation

@hakarrr

@hakarrr hakarrr commented Nov 13, 2026

Copy link
Copy Markdown

AppService.init calls asyncio.get_event_loop() at construction time. Python 3.14 no longer creates an implicit event loop, so constructing AppService on a thread with no preset loop raises RuntimeError. The server's own bootstrap (server.py) sets a loop for the main thread before services are constructed, so this change does not affect the installed server's startup; the crash appears when AppService is constructed without that bootstrap - as tests/services/test_magma_graceful_degradation.py does (fails by default on 3.14, passes on 3.13) - or under an explicitly absent loop on any version (asyncio.set_event_loop(None)).

This mirrors the guard merged for RestService in #3372. The new regression test fails without this change (3.13 and 3.14 with an explicitly absent loop) and passes with it.

Verification: CPython 3.14.9 - full tests/ tree run locally in 8 disjoint chunks (junit-verified union equals the collected set): 562 passed, 1 xfailed; the api managers file requires a config-loading test to run first, a pre-existing upstream order dependency, so its chunk runs test_health_api.py first. CPython 3.13.17 - targeted runs only (test_app_svc.py 7 passed; services/security/web/sigterm chunk green); a full 3.13 tree run was not performed. Changed files are flake8 (7.0.0 + bugbear, repo config) and bandit (1.7.7, repo-configured flags, run under 3.13 as bandit 1.7.7 cannot execute on 3.14) clean; the whole-tree bandit baseline carries 15 pre-existing low-severity findings, unchanged by this patch. No behavior change where a loop is already set. This does not add 3.14 to the supported or tested matrix; hosted CI remains the gate.

Related to #3368.

hakarrr and others added 2 commits November 13, 2026 12:11
…pache#3368)

Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
…ache#3368)

Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
@hakarrr

hakarrr commented Nov 13, 2026

Copy link
Copy Markdown
Author

Could a maintainer review this Python 3.14 AppService initialization fix for #3368? Please let me know if the event-loop handling needs changing or if additional cases are needed before it can move forward. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant