Repository navigation
Create an event loop before starting the app on Python 3.14 - #78
Draft
aiolibsbot wants to merge 1 commit into
Draft
aiolibsbot wants to merge 1 commit into
aiolibsbot wants to merge 1 commit into
Conversation
`anyio` v1 boots the app through `asyncio.get_event_loop()`, depending on it to implicitly create a loop when the main thread has none. Python 3.14 removed that fallback, so the call raises `RuntimeError: There is no current event loop in thread 'MainThread'` and the app never starts. `octomachinery` caps `anyio` below v2, so upgrading the dependency is not an option here. Creating the loop at the entry point instead restores exactly the behaviour the interpreter used to provide, leaves older Pythons unaffected and becomes a no-op once `octomachinery` grows `anyio` v2+ support. Verified by running `python -m patchback` under both interpreters: on 3.14 it now gets all the way to authenticating against the GitHub API instead of dying in `anyio`, and 3.13 behaves the same before and after. Refs sanitizers#71
This was referenced Sep 17, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Create an event loop at the entry point so the app boots on Python 3.14.
Why
Reproduced #71 locally on CPython 3.14.5. The traceback bottoms out in
anyiov1.4 (_backends/_asyncio.py:104), which starts the app withasyncio.get_event_loop()and relies on it implicitly creating a loop whenthe main thread has none. Python 3.14 removed that fallback, so it raises
RuntimeError: There is no current event loop in thread 'MainThread'.octomachinery0.3.11 declaresanyio <2.0.0, so patchback cannot resolvethis by unpinning — the real fix lives upstream.
Good news from the investigation: that one call is the only 3.14 blocker.
With a loop present, the whole stack (anyio → aiohttp → octomachinery →
gidgethub) runs fine on 3.14.
How
One guarded statement in
__main__.pydoing what the interpreter used to dofor us. It leaves older Pythons untouched and stops being necessary once
octomachinerysupportsanyiov2+ — the NOTE block says so.Testing
python -m patchbackwith throwaway App credentials, 2×2:RuntimeError: There is no current event loopgidgethub.BadRequest: Integration not foundgidgethub.BadRequest: Integration not foundgidgethub.BadRequest: Integration not foundIntegration not foundis the server rejecting the dummy App ID — i.e. theapp booted, started serving and made a real authenticated API call. 3.14 now
matches 3.13; 3.13 is unchanged.
Repro:
No unit test: the
anyioboot path needs the full dependency set plus Appcredentials, which a plain pytest job cannot provide honestly.
Refs #71
Quality Report
Changes: 1 file changed, 12 insertions(+)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan