python-trio / trio

Trio – a friendly Python library for async concurrency and I/O
https://trio.readthedocs.io
Other
6.12k stars 335 forks source link

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

Closed A5rocks closed 4 months ago

A5rocks commented 8 months ago

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: https://github.com/python-trio/trio/issues/2848

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

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/python-trio/trio/pull/2928?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio) | Coverage Δ | | |---|---|---| | [src/trio/\_core/\_io\_epoll.py](https://app.codecov.io/gh/python-trio/trio/pull/2928?src=pr&el=tree&filepath=src%2Ftrio%2F_core%2F_io_epoll.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX2NvcmUvX2lvX2Vwb2xsLnB5) | `100.00% <100.00%> (ø)` | |
A5rocks commented 8 months ago

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 commented 6 months ago

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

https://github.com/gevent/gevent/issues/2008

jakkdl commented 6 months ago

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

TeamSpen210 commented 4 months ago

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.