dabeaz / curio

Good Curio!
Other
4.01k stars 240 forks source link

Curio cannot be imported in python 3.12 #367

Open hyperrealist opened 4 months ago

hyperrealist commented 4 months ago

Importing curio in python 3.12 results in the following error:

In [1]: import curio
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 import curio

File ~/.local/miniconda3/envs/test-p312/lib/python3.12/site-packages/curio/__init__.py:6
      3 __version__ = '1.6'
      5 from .errors import *
----> 6 from .queue import *
      7 from .task import *
      8 from .time import *

File ~/.local/miniconda3/envs/test-p312/lib/python3.12/site-packages/curio/queue.py:20
     18 from .errors import CurioError, CancelledError
     19 from .meta import awaitable, asyncioable
---> 20 from . import workers
     22 __all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'UniversalQueue']
     24 class QueueBase:

File ~/.local/miniconda3/envs/test-p312/lib/python3.12/site-packages/curio/workers.py:23
     21 from .traps import _future_wait, _get_kernel
     22 from . import sync
---> 23 from .channel import Connection
     25 # Code to embed a traceback in a remote exception.  This is borrowed
     26 # straight from multiprocessing.pool.  Copied here to avoid possible
     27 # confusion when reading the traceback message (it will identify itself
     28 # as originating from curio as opposed to multiprocessing.pool).
     30 class RemoteTraceback(Exception):

File ~/.local/miniconda3/envs/test-p312/lib/python3.12/site-packages/curio/channel.py:31
     28 # Authentication parameters (copied from multiprocessing)
     30 AUTH_MESSAGE_LENGTH = mpc.MESSAGE_LENGTH    # 20
---> 31 CHALLENGE = mpc.CHALLENGE                   # b'#CHALLENGE#'
     32 WELCOME = mpc.WELCOME                       # b'#WELCOME#'
     33 FAILURE = mpc.FAILURE                       # b'#FAILURE#'

AttributeError: module 'multiprocessing.connection' has no attribute 'CHALLENGE'
klen commented 4 months ago

This has been fixed in a5590bb04de3f1f201fd1fd0ce9cfe5825db80ac, but packages wasn't updated 🤷‍♂️

The Curio project is no longer making package releases. I'm more than happy to accept bug reports and may continue to work on it from time to time as the mood strikes. If you want the absolute latest version, you should vendor the source code from here. Curio has no dependencies other than the Python standard library. --Dave

dabeaz commented 3 months ago

I'm not seeing a failure on Python 3.12 so it seems to be fixed at the moment.

klen commented 3 months ago

@dabeaz Installed the latest python 3.12.2 (Apr 8 2024) and the latest curio from pypi:

Python 3.12.2 (main, Apr  8 2024, 12:08:45) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import curio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/horneds/projects/asgi-tools/.venv/lib/python3.12/site-packages/curio/__init__.py", line 6, in <module>
    from .queue import *
  File "/Users/horneds/projects/asgi-tools/.venv/lib/python3.12/site-packages/curio/queue.py", line 20, in <module>
    from . import workers
  File "/Users/horneds/projects/asgi-tools/.venv/lib/python3.12/site-packages/curio/workers.py", line 23, in <module>
    from .channel import Connection
  File "/Users/horneds/projects/asgi-tools/.venv/lib/python3.12/site-packages/curio/channel.py", line 31, in <module>
    CHALLENGE = mpc.CHALLENGE                   # b'#CHALLENGE#'
                ^^^^^^^^^^^^^
AttributeError: module 'multiprocessing.connection' has no attribute 'CHALLENGE'. Did you mean: '_CHALLENGE'?
>>>

The issue is fixed on Github, but the pypi package is not updated 🤷‍♂️