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

Trio fails under gevent with NotImplementedError: unsupported platform #3013

Open
pg1671 opened this issue Jun 9, 2024 · 11 comments
Open

Trio fails under gevent with NotImplementedError: unsupported platform #3013

pg1671 opened this issue Jun 9, 2024 · 11 comments

Comments

@pg1671
Copy link

pg1671 commented Jun 9, 2024

Trio is installed as a dependancy of httpx.

If I run the code:

from gevent.monkey import patch_all; patch_all()
import gevent
import httpx

def worker(n):
     print(n)

if __name__ == '__main__':
    jobs = [gevent.spawn(worker, job_no) for job_no in range(10)]
    gevent.joinall(jobs)

I get:

Traceback (most recent call last):
  File "/tests/gevent_test.py", line 3, in
    import httpx
  File "/work/env3.11/lib/python3.11/site-packages/httpx/init.py", line 2, in
    from ._api import delete, get, head, options, patch, post, put, request, stream
  File "/work/env3.11/lib/python3.11/site-packages/httpx/_api.py", line 6, in
    from ._client import Client
  File "/work/env3.11/lib/python3.11/site-packages/httpx/_client.py", line 32, in
    from ._transports.default import AsyncHTTPTransport, HTTPTransport
  File "/work/env3.11/lib/python3.11/site-packages/httpx/_transports/default.py", line 32, in
    import httpcore
  File "/work/env3.11/lib/python3.11/site-packages/httpcore/init.py", line 1, in
    from ._api import request, stream
  File "/work/env3.11/lib/python3.11/site-packages/httpcore/_api.py", line 5, in
    from ._sync.connection_pool import ConnectionPool
  File "/work/env3.11/lib/python3.11/site-packages/httpcore/_sync/init.py", line 1, in
    from .connection import HTTPConnection
  File "/work/env3.11/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 12, in
    from .._synchronization import Lock
  File "/work/env3.11/lib/python3.11/site-packages/httpcore/_synchronization.py", line 11, in
    import trio
  File "/work/env3.11/lib/python3.11/site-packages/trio/init.py", line 23, in
    from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED # isort: split
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/env3.11/lib/python3.11/site-packages/trio/_core/init.py", line 21, in
    from ._local import RunVar, RunVarToken
  File "/work/env3.11/lib/python3.11/site-packages/trio/_core/_local.py", line 9, in
    from . import _run
  File "/work/env3.11/lib/python3.11/site-packages/trio/_core/_run.py", line 2840, in
    raise NotImplementedError("unsupported platform")
NotImplementedError: unsupported platform
@A5rocks
Copy link
Contributor

A5rocks commented Jun 10, 2024

Hi, what trio version are you using? (Just to double check, though I haven't tried to reproduce yet)

@pg1671
Copy link
Author

pg1671 commented Jun 10, 2024

Hi .. it was the latest 0.25.1.

@A5rocks
Copy link
Contributor

A5rocks commented Jun 10, 2024

While I'm not sure this will fix it, maybe try pip install git+https://github.com/python-trio/trio? #2928 was merged since v0.25.1 was released

@pg1671
Copy link
Author

pg1671 commented Jun 10, 2024

Hi .. it doesn't appear to fix it in the example code above. Still getting the same error.

@pg1671
Copy link
Author

pg1671 commented Jun 10, 2024

I tried the same commands as the top of #2928 and got the error as well.

I am using Python 3.11.

@CoolCat467
Copy link
Contributor

What operating system are you using?
If you can post the results of

python3.11 -m platform

that would be helpful.

@A5rocks
Copy link
Contributor

A5rocks commented Jun 10, 2024

We should probably include that in the assert message tbh.

I'm also curious about your platform because after pip install trio httpx gevent in a venv on Windows 11, I get this: (notice: no errors)

>>> from gevent.monkey import patch_all; patch_all()
True
>>> import gevent
>>> import httpx
>>>
>>> def worker(n):
...      print(n)
...
>>> if __name__ == '__main__':
...     jobs = [gevent.spawn(worker, job_no) for job_no in range(10)]
...     gevent.joinall(jobs)
...
0
1
2
3
4
5
6
7
8
9
[<Greenlet at 0x16460a8bce0: _run>, <Greenlet at 0x16460acbe20: _run>, <Greenlet at 0x16460acbec0: _run>, <Greenlet at 0x16460acbba0: _run>, <Greenlet at 0x16460acbf60: _run>, <Greenlet at 0x16460adc040: _run>, <Greenlet at 0x16460adc0e0: _run>, <Greenlet at 0x16460adc180: _run>, <Greenlet at 0x16460adc220: _run>, <Greenlet at 0x16460adc2c0: _run>]

... I assume some sort of Linux? Looking at the code, windows uses a set of primitives always, rather than trying to find something that works.

I think your error totally makes sense and we can probably figure something out (detecting gevent monkey patching?), I'm just surprised this hasn't happened before as far as I know. As a short term fix, when I pip install httpx it doesn't look like it pulls in trio, so I don't think that's a required dependency. Maybe your application will work after uninstalling trio to force httpx to use something else?

@CoolCat467
Copy link
Contributor

Because of the way the logic works, the system this is failing on is not windows, not linux, not epoll-based, and not kqueue-based. Given the what the select docs say, I predict the target system is Solaris or a Solaris derivative, which uses devpoll for polling.

@CoolCat467
Copy link
Contributor

Might not actually go anywhere because of issues with getting a solaris runner in CI, but created #3014 for attempting to add solaris support

@njsmith
Copy link
Member

njsmith commented Jun 10, 2024 via email

@pg1671
Copy link
Author

pg1671 commented Jun 10, 2024

Hi, the platform is ubuntu 22.04.

Here is the output from python3.11 -m platform:

Linux-6.5.0-1018-aws-x86_64-with-glibc2.35

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

No branches or pull requests

4 participants