Skip to content

Ensure that all async generators are explicitly closed - #30

Merged
florimondmanca merged 3 commits into
florimondmanca:masterfrom
agronholm:asyncgenerators
Jun 18, 2025
Merged

Ensure that all async generators are explicitly closed#30
florimondmanca merged 3 commits into
florimondmanca:masterfrom
agronholm:asyncgenerators

Conversation

@agronholm

Copy link
Copy Markdown
Contributor

If this is not done, it will be up to the event loop's asyncgen finalizer to do the closing, and there's no telling when it will happen. Additionally, Trio will emit a warning whenever the finalizer detects an unclosed async generator.

@agronholm

Copy link
Copy Markdown
Contributor Author

This is part of my efforts to clean up asyncgen usage in httpx/httpcore to get MCP working with Trio.

@florimondmanca florimondmanca left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Sure, thanks!

Comment thread src/httpx_sse/_api.py Outdated
Comment thread src/httpx_sse/_api.py Outdated
Comment thread src/httpx_sse/_api.py Outdated
@florimondmanca
florimondmanca merged commit b1d12bb into florimondmanca:master Jun 18, 2025
4 checks passed
@agronholm

Copy link
Copy Markdown
Contributor Author

I am also working on PRs against httpcore and httpx, see encode/httpcore#1019

@agronholm
agronholm deleted the asyncgenerators branch June 18, 2025 18:35
@agronholm

Copy link
Copy Markdown
Contributor Author

Could I ask for a new release too? 🙏

@florimondmanca

Copy link
Copy Markdown
Owner

Ah yes, will do

@florimondmanca florimondmanca mentioned this pull request Jun 24, 2025
@florimondmanca

Copy link
Copy Markdown
Owner

@agronholm

Copy link
Copy Markdown
Contributor Author

Ah yes, will do

Much obliged! 🎉

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