-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed as not planned
Closed as not planned
Copy link
Description
This issue tracks the implementation PRs for adopting proven Trio/anyio patterns natively into asyncio, as proposed in the discuss.python.org thread: Adopt proven anyio/Trio patterns natively into asyncio (multi-release roadmap).
PRs
Tier 1 — Structured concurrency foundations
- Add asyncio.CancelScope with level-triggered cancellation #145345 — CancelScope:
asyncio.CancelScopewith level-triggered cancellation,cancel_scope()/cancel_scope_at()convenience APIs. Implements per-task scope stack with zero overhead for code not using scopes. (51 tests) - Add TaskGroup.start() and TaskStatus for task readiness signaling #145353 — TaskGroup.start():
TaskGroup.start()andTaskStatusfor task readiness signaling — lets a long-running task signal when it's ready while continuing to run in the group. (8 tests)
Tier 2 — Resource management & communication
- Add asyncio.CapacityLimiter with borrower tracking and dynamic capacity #145354 — CapacityLimiter:
asyncio.CapacityLimiterwith borrower tracking, dynamictotal_tokens,on_behalf_ofAPI, and FIFO fairness. Improves onSemaphoreby preventing same-task deadlocks. (15 tests) - Add asyncio memory object channels (open_channel) #145356 — Memory channels:
asyncio.open_channel()with splitSendChannel/ReceiveChannelendpoints, bounded backpressure, clone + ref-counting, and clean shutdown signaling. Improves onasyncio.Queue. (40 tests) - Add asyncio async file I/O (open_file, AsyncFile, wrap_file, Path) #145358 — Async file I/O:
asyncio.open_file(),AsyncFile,wrap_file(),Path— thread-delegated async file I/O wrappingopen()andpathlib.Path. (55 tests)
Design principles
All implementations follow the same approach:
- Adopt proven patterns — APIs closely mirror battle-tested Trio/anyio designs
- Pure Python where possible (only CancelScope touches C code for Task internals)
- Zero overhead for existing code — no behavioral changes unless new APIs are explicitly used
- Reuse existing asyncio infra —
to_thread(),create_future(),create_task(), etc. - Comprehensive test coverage — 169 new tests total across all PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels