Skip to content

DRAFT: anyio port - #330

Draft
msullivan wants to merge 13 commits into
mainfrom
ANYIO
Draft

msullivan wants to merge 13 commits into
mainfrom
ANYIO

Conversation

@msullivan

Copy link
Copy Markdown
Collaborator

I wrote a long message but the gh client ate it.

A souped up decouple is used to protect async generators.

After building it I discovered that trio (but not anyio) has something
analagous: as_safe_channel.

Some stuff works under trio. I've found stuff that fails though.

I'll need to think more about cancellation; running user callbacks in
anyio tasks basically requires the users to use anyio if they want to
do cancellation safe cleanup, which is not great. (It is possible
though annoying to do cancellation safe cleanup in pure asyncio.)

@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai-python Ready Ready Preview, v0 Oct 26, 2026 10:48pm UTC

@socket-security

socket-security Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​anyio@​4.15.197100100100100
Addedpypi/​typing-extensions@​4.16.0100100100100100

View full report

…safe

By cancellation-safe I mean that it will not kill the stream or drop data.
cancel_hook() used to cancel the asyncio future, delivering a
CancelledError that no cancel scope owns. Raise a new HookCancelled
exception in the awaiter instead. A duplicate resolve_hook() on a live
hook raises FutureAlreadyFinished.
Under anyio a cancel scope stays cancelled, so code that catches a
cancel and keeps going would lose the span's closing push.
MultiWaiter now waits on anything with an async wait() method, using
a watcher task per item in its own task group, so it must be entered
as an async context manager.

ToolRunner uses util.create_task_group() and schedule() returns an
anyio.TaskHandle. BoundToolCall catches anyio's cancel class so that
cancelling a tool through its handle still produces an error result.

This branch was successfully deployed

1 active deployment
Preview — f1708262 Deployed Oct 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant