On 2025-01-31 14:01:15, Thomas Goirand wrote:
> FYI, a simple way to reproduce:
>
> apt-get install python3-keystoneauth1 python3-osprofiler python3-trio
> python3 -c "from keystoneauth1 import session as keystone_session"
>
> This shows that trio is conflicting with osprofiler + eventlet + 
> dnspython, and as keystoneauth1 loads osprofiler when it sees it as 
> installed, we see such a crash.
>
> This is probably due to Eventlet monkey-patching of the stdlib socket 
> library.
>
> However, I don't think this should be considered an RC bug, since 
> osprofiler is only used for OpenStack, and that OpenStack doesn't use 
> Trio. So there's a very small chance to get this triggered.
>
> Moving forward, I'm not sure what to do. Maybe simply to have osprofiler 
> to Conflict: with trio?

I don't think this issue is solely with osprofiler.

Here, I'm trying to package python-manhole (#1106776) and I've stumbled
upon this. I can't reproduce in a virtualenv:

python3 -m venv ~/.venvs/manhole
~/.venvs/manhole/bin/pip install manhole trio eventlet
~/.venvs/manhole/bin/python -c 'import manhole'

that works fine.

Yet this, in my normal environment, crashes with:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import manhole
  File "/usr/lib/python3/dist-packages/manhole/__init__.py", line 44, in 
<module>
    from eventlet.patcher import original as _original
  File "/usr/lib/python3/dist-packages/eventlet/__init__.py", line 6, in 
<module>
    from eventlet import convenience
  File "/usr/lib/python3/dist-packages/eventlet/convenience.py", line 7, in 
<module>
    from eventlet.green import socket
  File "/usr/lib/python3/dist-packages/eventlet/green/socket.py", line 21, in 
<module>
    from eventlet.support import greendns
  File "/usr/lib/python3/dist-packages/eventlet/support/greendns.py", line 78, 
in <module>
    setattr(dns, pkg, import_patched('dns.' + pkg))
                      ~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/eventlet/support/greendns.py", line 60, 
in import_patched
    return patcher.import_patched(module_name, **modules)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/eventlet/patcher.py", line 136, in 
import_patched
    return inject(
        module_name, None, *additional_modules + 
tuple(kw_additional_modules.items())
    )
  File "/usr/lib/python3/dist-packages/eventlet/patcher.py", line 113, in inject
    module = __import__(module_name, {}, {}, module_name.split(".")[:-1])
  File "/usr/lib/python3/dist-packages/dns/asyncquery.py", line 40, in <module>
    from dns.query import (
    ...<12 lines>...
    )
  File "/usr/lib/python3/dist-packages/dns/query.py", line 66, in <module>
    import httpcore._backends.sync
  File "/usr/lib/python3/dist-packages/httpcore/__init__.py", line 1, in 
<module>
    from ._api import request, stream
  File "/usr/lib/python3/dist-packages/httpcore/_api.py", line 7, in <module>
    from ._sync.connection_pool import ConnectionPool
  File "/usr/lib/python3/dist-packages/httpcore/_sync/__init__.py", line 1, in 
<module>
    from .connection import HTTPConnection
  File "/usr/lib/python3/dist-packages/httpcore/_sync/connection.py", line 14, 
in <module>
    from .._synchronization import Lock
  File "/usr/lib/python3/dist-packages/httpcore/_synchronization.py", line 12, 
in <module>
    import trio
  File "/usr/lib/python3/dist-packages/trio/__init__.py", line 25, in <module>
    from . import abc, from_thread, lowlevel, socket, to_thread
  File "/usr/lib/python3/dist-packages/trio/socket.py", line 16, in <module>
    from . import _socket
  File "/usr/lib/python3/dist-packages/trio/_socket.py", line 542, in <module>
    class SocketType:
    ...<221 lines>...
                raise NotImplementedError
  File "/usr/lib/python3/dist-packages/trio/_socket.py", line 755, in SocketType
    @_wraps(_stdlib_socket.socket.sendmsg, assigned=(), updated=())
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'GreenSocket' has no attribute 'sendmsg'

I've filed this against manhole in
https://github.com/ionelmc/python-manhole/issues/70 and have found a
patch there, but it seems to me, maybe, we should move this to the
eventlet package?

A.

-- 
Men often become what they believe themselves to be. If I believe I
cannot do something, it makes me incapable of doing it. But when I
believe I can, then I acquire the ability to do it even if I didn't
have it in the beginning.
                         - Mahatma Gandhi

Reply via email to