You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
async generator allows concurrent access via async_gen_athrow_throw and async_gen_asend_throw #117881
I'm getting lost in this, and I guess I'm not the only one.
I started mapping out the state machine like this:
async_gen_unwrap_value:
ag_running_async ag_closed result
------------------------------------------
yes (any) - unchanged; no exception
- ag_running_async=0; exception set
- ag_running_async=0; ag_closed=1; exception set
no (any) shouldn't happen? (Should we add an `assert` for this?)
async_gen_asend_send:
ags_state ag_running_async ag_closed result
-------------------------------------------------
CLOSED (any) (any) error: cannot reuse already awaited __anext__()/asend()
INIT yes (any) error: anext(): asynchronous generator is already running
INIT no (any) ags_state=ITER; continue with the ags_state=ITER case
ITER (any) (any) - ag_running_async=1; no exception
- ag_running_async=0; ags_state=CLOSED; exception set
- ag_running_async=0; ag_closed=1; ags_state=CLOSED; exception set
but I remembered have other tasks lined up before 3.13 beta 1, and I probably shouldn't go too deep in this rabbit hole right now.
Do you think a map like this would help find similar bugs? Does something similar already exist?
Activity
graingert commentedon Apr 15, 2024
the problem is async_gen_athrow_throw and async_gen_asend_throw are not setting/checking
o->agt_gen->ag_running_asyncpythonGH-117881: fix athrow().throw()/asend().throw() concurrent access
graingert commentedon Apr 15, 2024
a demo showing that this is reproducible using asyncio, as well as manual generator manipulation:
outputs:
encukou commentedon Apr 25, 2024
I'm getting lost in this, and I guess I'm not the only one.
I started mapping out the state machine like this:
but I remembered have other tasks lined up before 3.13 beta 1, and I probably shouldn't go too deep in this rabbit hole right now.
Do you think a map like this would help find similar bugs? Does something similar already exist?
GH-117881: fix athrow().throw()/asend().throw() concurrent access (GH…
[3.12] GH-117881: fix athrow().throw()/asend().throw() concurrent acc…
encukou commentedon May 6, 2024
@graingert Does my question make sense?
graingert commentedon May 6, 2024
@encukou yes, I think it would be useful - where should it go? In the docs or just in a comment in genobject.c?
encukou commentedon May 6, 2024
A comment is fine. If it's too long, it could be a separate document referenced from genobject.c.
Or possibly the devguide, if pretty rendering would be worth writing it in ReST. Not the user-facing docs though.
pythonGH-117881: fix athrow().throw()/asend().throw() concurrent acce…
Fix AsyncGenerator following CPython (GH-7777)