Skip to content

Conversation

@colesbury
Copy link
Contributor

@colesburycolesbury commented Jan 27, 2026

Add a FRAME_SUSPENDED_YIELD_FROM_LOCKED state that acts as a brief lock, preventing other threads from transitioning the frame state while gen_getyieldfrom reads the yield-from object off the stack.

Add a FRAME_SUSPENDED_YIELD_FROM_LOCKED state that acts as a brief lock, preventing other threads from transitioning the frame state while gen_getyieldfrom reads the yield-from object off the stack.
@colesburycolesbury marked this pull request as ready for review January 28, 2026 16:44
@colesburycolesbury requested a review from mpageJanuary 28, 2026 16:44
Copy link
Contributor

@mpagempage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I worry a little about the increasing complexity in the state machine. Specifically, that folks might forget to call gen_yield_from_lock_wait() at the beginning of the state transition loop. Would it be worth factoring out the common logic?

@colesbury
Copy link
ContributorAuthor

Hmmm.. maybe we can handle it in _Py_GEN_TRY_SET_FRAME_STATE

@colesburycolesbury requested a review from mpageJanuary 29, 2026 21:24
@colesbury
Copy link
ContributorAuthor

I've move the retry logic into _Py_GEN_TRY_SET_FRAME_STATE. @mpage would you please take a look at the most recent changes?

Copy link
Contributor

@mpagempage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@colesburycolesbury merged commit a01694d into python:mainJan 30, 2026
53 checks passed
@colesburycolesbury deleted the gh-120321-yield-from branch January 30, 2026 17:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@colesbury@mpage