Skip to content

Conversation

@anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Jan 8, 2026

The into_stream glue code provides backpressure on the wrapped async generator when its internal buffer is full. This is done by returning a future that resolves after the buffer flushes and the item sent. But a future is not a coroutine so the iscoroutine check currently used always returns False and the future is never awaited. This causes the generator to continue to be pulled non-stop until completion, at which point the glue's tx will be closed even though there are still pending sends, causing them to be missed.

The correct check is isawaitable to detect asyncio.Future.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks, this makes sense to me, I verified both that I agree with the test and that the fix does indeed resolve the test.

@davidhewitt davidhewitt merged commit d78a63b into PyO3:main Jan 15, 2026
36 checks passed
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.

2 participants