Skip to content

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

Merged
A5rocks merged 7 commits into
python-trio:masterfrom
A5rocks:import-under-gevent
May 31, 2024
Merged

A5rocks merged 7 commits into
python-trio:masterfrom
A5rocks:import-under-gevent

Conversation

@A5rocks

@A5rocks A5rocks commented Jan 17, 2024 •

Copy link
Copy Markdown
Contributor

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

codecov Bot commented Jan 17, 2024 •

Copy link
Copy Markdown

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 with missing lines Coverage Δ
src/trio/_core/_io_epoll.py 100.00% <100.00%> (ø)

@A5rocks

A5rocks commented Jan 17, 2024 •

Copy link
Copy Markdown
Contributor Author

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

neevista commented Apr 1, 2024

Copy link
Copy Markdown

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

gevent/gevent#2008

@jakkdl

jakkdl commented Apr 1, 2024

Copy link
Copy Markdown
Member

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

@CoolCat467 CoolCat467 left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

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