-
Progress replacing asyncio with anyio (#2143)
发布于
2025-10-19 18:08:06 +00:00 | 1622 次提交 在此版本后已推送到 main- Replace asyncio.sleep() with anyio.sleep()
- Replace asyncio.sleep() in error_handling.py retry middleware
- Replace asyncio.sleep() in oauth.py callback shutdown
- Keep asyncio.TimeoutError check for Python 3.10 compatibility
- Add anyio import to error_handling.py
All core library sleep calls now use anyio primitives. Tests and
example code still use asyncio where appropriate.- Replace OAuth asyncio.Future with anyio.Event pattern
- Create OAuthCallbackResult dataclass for result storage
- Replace Future with Event + result container pattern
- Update oauth_callback.py to use anyio.Event coordination
- Update auth/oauth.py callback_handler to use Event pattern
- Remove asyncio imports from OAuth flow
OAuth callback now uses anyio primitives for async coordination
instead of asyncio.Future.- Remove asyncio fire-and-forget task hack from Context
- Remove _try_flush_notifications() method entirely
- Update queue*_list_changed() to only queue notifications
- Remove asyncio import from context.py
- Keep _flush_notifications() for deferred sending on context exit
Notifications now flush reliably on request completion (aexit)
instead of attempting immediate delivery with asyncio.create_task().
Slight delay is acceptable - all notifications are deduplicated and
sent when the MCP request handler completes.下载附件