-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error message for eventlet/gevent monkey patching #3140
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also unable to test myself, but looks good as far as I can tell
@yurivict would you mind testing this to make sure the better error message appears? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the error message could be improved by saying which patchers are present, I'll suggest a change
if "eventlet" in sys.modules or "gevent" in sys.modules: | ||
raise NotImplementedError( | ||
"unsupported platform or primitives trio depends on are monkey-patched out", | ||
) | ||
else: | ||
raise NotImplementedError("unsupported platform") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe something like this?
if "eventlet" in sys.modules or "gevent" in sys.modules: | |
raise NotImplementedError( | |
"unsupported platform or primitives trio depends on are monkey-patched out", | |
) | |
else: | |
raise NotImplementedError("unsupported platform") | |
_patchers = sorted({"eventlet", "gevent"}.intersection(sys.modules.keys())) | |
if _patchers: | |
raise NotImplementedError( | |
"unsupported platform or primitives trio depends on are monkey-patched out by {_patchers}", | |
) | |
else: | |
raise NotImplementedError("unsupported platform") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Else block is unnecessary after raise statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah of course
Fixes #3087
Unfortunately I am unable to check this because I only have Linux and Windows available. This only happens on MacOS.