forked from modelcontextprotocol/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_compat.py
More file actions
19 lines (14 loc) · 815 Bytes
/
_compat.py
File metadata and controls
19 lines (14 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""Workarounds for CPython interpreter bugs the SDK papers over."""
import anyio.lowlevel
__all__ = ["resync_tracer"]
async def resync_tracer() -> None:
"""Resync coverage tracing after a cancelled task-group join.
A cancel delivered at a join resumes the awaiting coroutine chain via
`coro.throw()`; on CPython 3.11 (python/cpython#106749) that drops the
`'call'` trace events for the outer frames and desyncs coverage's CTracer
until the chain next suspends and resumes normally. Yielding once here
resumes via `.send()`, which re-stamps the missing events. Shielded so a
pending outer cancel is not re-delivered at this point; behaviorally a
no-op. Delete this module when Python 3.11 support ends (EOL 2027-10).
"""
await anyio.lowlevel.cancel_shielded_checkpoint()