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

Run-time failure on FreeBSD: NotImplementedError: unsupported platform #3087

Closed
yurivict opened this issue Sep 13, 2024 · 7 comments · Fixed by #3140
Closed

Run-time failure on FreeBSD: NotImplementedError: unsupported platform #3087

yurivict opened this issue Sep 13, 2024 · 7 comments · Fixed by #3140

Comments

@yurivict
Copy link

When both wandb and eventlet packages are installed 'import wandb' fails in the trio code:

$ python3.11
Python 3.11.9 (main, Jul 11 2024, 01:05:32) [Clang 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> import wandb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/wandb/__init__.py", line 20, in <module>
    from wandb import sdk as wandb_sdk
  File "/usr/local/lib/python3.11/site-packages/wandb/sdk/__init__.py", line 28, in <module>
    from .wandb_init import _attach, init
  File "/usr/local/lib/python3.11/site-packages/wandb/sdk/wandb_init.py", line 32, in <module>
    from . import wandb_login, wandb_setup
  File "/usr/local/lib/python3.11/site-packages/wandb/sdk/wandb_login.py", line 25, in <module>
    from .wandb_settings import Settings
  File "/usr/local/lib/python3.11/site-packages/wandb/sdk/wandb_settings.py", line 45, in <module>
    from wandb.sdk.internal.system.env_probe_helpers import is_aws_lambda
  File "/usr/local/lib/python3.11/site-packages/wandb/sdk/internal/system/env_probe_helpers.py", line 3, in <module>
    from sentry_sdk.integrations.aws_lambda import get_lambda_bootstrap  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/__init__.py", line 1, in <module>
    from sentry_sdk.hub import Hub, init
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/hub.py", line 9, in <module>
    from sentry_sdk.scope import Scope
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/scope.py", line 7, in <module>
    from sentry_sdk.utils import logger, capture_internal_exceptions
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1048, in <module>
    HAS_REAL_CONTEXTVARS, ContextVar = _get_contextvars()
                                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1018, in _get_contextvars
    if not _is_contextvars_broken():
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/utils.py", line 979, in _is_contextvars_broken
    from eventlet.patcher import is_monkey_patched  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/eventlet/__init__.py", line 6, in <module>
    from eventlet import convenience
  File "/usr/local/lib/python3.11/site-packages/eventlet/convenience.py", line 7, in <module>
    from eventlet.green import socket
  File "/usr/local/lib/python3.11/site-packages/eventlet/green/socket.py", line 21, in <module>
    from eventlet.support import greendns
  File "/usr/local/lib/python3.11/site-packages/eventlet/support/greendns.py", line 78, in <module>
    setattr(dns, pkg, import_patched('dns.' + pkg))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/eventlet/support/greendns.py", line 60, in import_patched
    return patcher.import_patched(module_name, **modules)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/eventlet/patcher.py", line 132, in import_patched
    return inject(
           ^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/eventlet/patcher.py", line 109, in inject
    module = __import__(module_name, {}, {}, module_name.split('.')[:-1])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dns/asyncquery.py", line 32, in <module>
    import dns.quic
  File "/usr/local/lib/python3.11/site-packages/dns/quic/__init__.py", line 37, in <module>
    import trio
  File "/usr/local/lib/python3.11/site-packages/trio/__init__.py", line 23, in <module>
    from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED  # isort: split
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/trio/_core/__init__.py", line 21, in <module>
    from ._local import RunVar, RunVarToken
  File "/usr/local/lib/python3.11/site-packages/trio/_core/_local.py", line 9, in <module>
    from . import _run
  File "/usr/local/lib/python3.11/site-packages/trio/_core/_run.py", line 2844, in <module>
    raise NotImplementedError("unsupported platform")
NotImplementedError: unsupported platform

The conditional in this line:

elif TYPE_CHECKING or hasattr(select, "kqueue"):

always evaluates to False because TYPE_CHECKING is always False at run-time.
Otherwise hasattr(select, "kqueue") evaluates to True.

Version: 0.26.2
Python-3.11
FreeBSD 14.1

@A5rocks
Copy link
Contributor

A5rocks commented Sep 13, 2024

hasattr(select, "kqueue") must be False for that to be False fwiw

@yurivict
Copy link
Author

When I run it separately, hasattr(select, "kqueue") evaluates to True.
I don't know how can that be.

@A5rocks
Copy link
Contributor

A5rocks commented Sep 13, 2024

Yeah, because eventlet patches out select.kqueue. If you import trio first things should work... we should probably make the error message better.

@yurivict
Copy link
Author

It shouldn't fail like this. This failure is very obscure. I accidentally caught this while testing wandb after having other things installed by something else.

@A5rocks
Copy link
Contributor

A5rocks commented Sep 13, 2024

Would this as an error message work better?: "unsupported platform or the IO primitives trio relies on are patched out" if either eventlet or gevent are detected in sys.modules?

@yurivict
Copy link
Author

I guess this error message is okay.

The real problem seems to lie in the eventlet package.
It fails like this on import.

@CoolCat467
Copy link
Member

This is because eventlet does some nasty monkeypatching stuff and replaces signal handlers with its own

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 a pull request may close this issue.

3 participants