Skip to content

Give the worker a current_task before wait_for and TaskGroup - #375

Open
gyanu2507 wants to merge 1 commit into
pgjones:mainfrom
gyanu2507:fix/py314-task-context
Open

gyanu2507 wants to merge 1 commit into
pgjones:mainfrom
gyanu2507:fix/py314-task-context

Conversation

@gyanu2507

@gyanu2507 gyanu2507 commented Sep 18, 2026

Copy link
Copy Markdown

Fixes #351. Same crash as #354.

_run uses asyncio.Runner.run(). On Python 3.14 that task can eager-start, so the first await asyncio.wait_for(...) in worker_serve (lifespan startup) runs with current_task() still None. 3.14's timeout() raises RuntimeError: Timeout should be used inside a task and the worker dies before it binds.

Yield once inside the wrapped main so wait_for / TaskGroup see a real task. Tested _run against wait_for.

Python 3.14 can eager-start the Runner task. wait_for then calls
timeout() with current_task() still None and the worker dies on
startup.

Fixes pgjones#351
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.

Python 3.14 compatibility - TaskGroup, wait_for, and timeout require task context

1 participant