Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

A5rocks
Copy link
Contributor

@A5rocks A5rocks commented Nov 19, 2024

Fixes #3087

Unfortunately I am unable to check this because I only have Linux and Windows available. This only happens on MacOS.

Copy link
Member

@CoolCat467 CoolCat467 left a 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

@A5rocks
Copy link
Contributor Author

A5rocks commented Nov 19, 2024

@yurivict would you mind testing this to make sure the better error message appears?

Copy link
Member

@graingert graingert left a 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

Comment on lines +2956 to +2961
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like this?

Suggested 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")
_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")

Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah of course

@graingert graingert dismissed their stale review November 21, 2024 10:02

my review should not be blocking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run-time failure on FreeBSD: NotImplementedError: unsupported platform
3 participants