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

Just delay select.epoll to fix import after gevent monkey patching #2928

Merged
merged 7 commits into from
May 31, 2024

Conversation

A5rocks
Copy link
Contributor

@A5rocks A5rocks commented Jan 17, 2024

This seems to work:

Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent.monkey
>>> gevent.monkey.patch_all()
True
>>> import trio
>>> exit()

Fixes: #2848

... While trio still doesn't work under gevent, I think not erroring when importing is a good property to have.

@A5rocks A5rocks changed the title Just delay select.epoll to fix import with gevent monkey patching Just delay select.epoll to fix import after gevent monkey patching Jan 17, 2024
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.63%. Comparing base (71457f7) to head (4bd7afa).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2928   +/-   ##
=======================================
  Coverage   99.63%   99.63%           
=======================================
  Files         120      120           
  Lines       17865    17865           
  Branches     3212     3213    +1     
=======================================
  Hits        17800    17800           
  Misses         46       46           
  Partials       19       19           
Files Coverage Δ
src/trio/_core/_io_epoll.py 100.00% <100.00%> (ø)

@A5rocks
Copy link
Contributor Author

A5rocks commented Jan 17, 2024

cc @jeongilpark could you see if this works for you? I'm not sure if you're actually ending up using trio. (if you do, maybe we should do a better solution, like... I don't know, maybe use gevent.monkey.get_original? or... idk this level of trio very well.)

@neevista
Copy link

neevista commented Apr 1, 2024

@jakkdl @CoolCat467 - is this issue and the one specifically listed below resolved now?

gevent/gevent#2008

@jakkdl
Copy link
Member

jakkdl commented Apr 1, 2024

@jakkdl @CoolCat467 - is this issue and the one specifically listed below resolved now?

gevent/gevent#2008

no? I don't see any reason why they've would've been fixed with no changes to any code.

Copy link
Contributor

@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.

Seems simple enough, while obviously not fixing the underlying issue I think not crashing on import is important.

@TeamSpen210
Copy link
Contributor

Might be a good idea to add a comment as to why we're using a lambda here. Otherwise someone coming along in the future might "optimise" that out, especially since I know PyLint and therefore Ruff has a rule which would flag this.

@A5rocks A5rocks merged commit 93933b5 into python-trio:master May 31, 2024
28 checks passed
@A5rocks A5rocks deleted the import-under-gevent branch May 31, 2024 02:20
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.

AttributeError: module 'select' has no attribute 'epoll'
5 participants