Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"RuntimeError: cannot reuse already awaited coroutine" since 08bc03ff (under PYTHONASYNCIODEBUG) #143939

Closed
Labels
@vytas7

Description

@vytas7

Bug report

Bug description:

When runningFalcon's CI on 3.15, we started experiencing a strange error that I cannot really understand.

See, e.g.,https://github.com/falconry/falcon/actions/runs/21010040119/job/60402427099:

<...>        resp_event_collector = helpers.ASGIResponseEventCollector()            if not _one_shot:            task_req = asyncio.create_task(                app(http_scope, req_event_emitter, resp_event_collector)            )                if _stream_result:                # NOTE(kgriffs): Wait until the response has been started and give                #   the task a chance to progress. Otherwise, we won't have a                #   status or headers to pass to StreamedResult.                while not resp_event_collector.status:                    await asyncio.sleep(0)                    return StreamedResult(                    resp_event_collector.body_chunks,                    code_to_http_status(resp_event_collector.status),                    resp_event_collector.headers,                    task_req,                    req_event_emitter,                )                req_event_emitter.disconnect()>           await task_reqE           RuntimeError: cannot reuse already awaited coroutine

task_req is created above usingasyncio.create_task(...), and normally it can beawaited as many times as desired.

Printing it just before the failure gives:

<Task pending name='Task-3' coro=<App.__call__() running at /tmp/falcon/falcon/asgi/app.py:459> created at /usr/local/lib/python3.15/asyncio/tasks.py:395>

Interestingly, the error is only raised when running underPYTHONASYNCIODEBUG=1. Otherwise it passes just fine.

I was unable to isolate an independent MRE... Using Falcon's source tree @falconry/falcon@6432f40, the following is enough to reproduce, given a venv using CPython dev version:

FALCON_DISABLE_CYTHON=1 pip install -e . pytest# Works fine without asyncio debug: pytest tests/asgi/test_sse.pyPYTHONASYNCIODEBUG=1 pytest tests/asgi/test_sse.py

I ran a similar script undergit bisect (first compiling the whole CPython source tree from scratch in a container), and bisected it down to this commit:

commit08bc03f
Author: Sam Grosscolesbury@gmail.com
Date: Fri Dec 19 14:10:37 2025 -0500

cc@colesbury@hugovk

CPython versions tested on:

3.15, CPython main branch

Operating systems tested on:

Linux

Other

I'm not sure whether this is a bug in CPython, or just sloppy code on our end...
But I find the error itself, and the fact that it only happens underPYTHONASYNCIODEBUG=1, puzzling.

Thanks in advance for any ideas!

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp