Skip to content

Commit 7d9c4a6

Browse files
A5rocksgraingert
andauthored
Improve error message for eventlet/gevent monkey patching (#3140)
* Improve error message for eventlet/gevent monkey patching * Add a newsfragment * Update src/trio/_core/_run.py Co-authored-by: Thomas Grainger <[email protected]> * Clean up a bit --------- Co-authored-by: Thomas Grainger <[email protected]>
1 parent 532ba5f commit 7d9c4a6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

newsfragments/3087.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve error message when run after gevent's monkey patching.

src/trio/_core/_run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,13 @@ async def checkpoint_if_cancelled() -> None:
29532953
_KqueueStatistics as IOStatistics,
29542954
)
29552955
else: # pragma: no cover
2956+
_patchers = sorted({"eventlet", "gevent"}.intersection(sys.modules))
2957+
if _patchers:
2958+
raise NotImplementedError(
2959+
"unsupported platform or primitives trio depends on are monkey-patched out by "
2960+
+ ", ".join(_patchers),
2961+
)
2962+
29562963
raise NotImplementedError("unsupported platform")
29572964

29582965
from ._generated_instrumentation import *

0 commit comments

Comments
 (0)