uvloop icon indicating copy to clipboard operation
uvloop copied to clipboard

uvloop fails on 3.14

Open graingert opened this issue 1 year ago • 6 comments

ImportError while loading conftest '/home/runner/work/anyio/anyio/tests/conftest.py'.
tests/conftest.py:17: in <module>
    import uvloop
/opt/hostedtoolcache/Python/3.14.0-alpha.1/x64/lib/python3.14/site-packages/uvloop/__init__.py:9: in <module>
    from .loop import Loop as __BaseLoop  # NOQA
uvloop/includes/stdlib.pxi:47: in init uvloop.loop
    ???
E   AttributeError: module 'asyncio' has no attribute 'AbstractChildWatcher'

graingert avatar Oct 20 '24 20:10 graingert

Ah, this has been deprecated since Python 3.12 and will be removed in 3.14. Let's get rid of it in uvloop too.

fantix avatar Oct 21 '24 16:10 fantix

With Python 3.14.0a5 there's one more thing happening:

________________ ERROR collecting _empty/tests/test_aiohttp.py _________________
ImportError while importing test module '/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_aiohttp.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_aiohttp.py:14: in <module>
    from uvloop import _testbase as tb
../../BUILDROOT/usr/lib64/python3.14/site-packages/uvloop/__init__.py:6: in <module>
    from asyncio.events import BaseDefaultEventLoopPolicy as __BasePolicy
E   ImportError: cannot import name 'BaseDefaultEventLoopPolicy' from 'asyncio.events' (/usr/lib64/python3.14/asyncio/events.py)

befeleme avatar Mar 12 '25 10:03 befeleme

ImportError: cannot import name 'BaseDefaultEventLoopPolicy' from 'asyncio.events'

I reported that part as https://github.com/python/cpython/issues/131148

hroncok avatar Mar 12 '25 13:03 hroncok

I attempted to do something in https://github.com/MagicStack/uvloop/pull/658, but it doesn't work correctly.

I still get:

=================================== FAILURES ===================================
________________________ TestBaseAIO.test_set_task_name ________________________
Traceback (most recent call last):
  File "/usr/lib64/python3.14/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib64/python3.14/unittest/case.py", line 660, in run
    self._callTestMethod(testMethod)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib64/python3.14/unittest/case.py", line 606, in _callTestMethod
    result = method()
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_base.py", line 594, in test_set_task_name
    self.assertEqual(result, "mytask!")
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/unittest/case.py", line 916, in assertEqual
    assertion_func(first, second, msg=msg)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/unittest/case.py", line 909, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: None != 'mytask!'
________________ TestUVExecutors.test_executors_process_pool_01 ________________
Traceback (most recent call last):
  File "/usr/lib64/python3.14/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib64/python3.14/unittest/case.py", line 660, in run
    self._callTestMethod(testMethod)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib64/python3.14/unittest/case.py", line 606, in _callTestMethod
    result = method()
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_executors.py", line 35, in test_executors_process_pool_01
    self.run_pool_test(concurrent.futures.ProcessPoolExecutor)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_executors.py", line 29, in run_pool_test
    self.loop.run_until_complete(run())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_executors.py", line 24, in run
    res = await asyncio.gather(*coros)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
_______________ TestAIOExecutors.test_executors_process_pool_01 ________________
Traceback (most recent call last):
  File "/usr/lib64/python3.14/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib64/python3.14/unittest/case.py", line 660, in run
    self._callTestMethod(testMethod)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib64/python3.14/unittest/case.py", line 606, in _callTestMethod
    result = method()
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_executors.py", line 35, in test_executors_process_pool_01
    self.run_pool_test(concurrent.futures.ProcessPoolExecutor)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_executors.py", line 29, in run_pool_test
    self.loop.run_until_complete(run())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/usr/lib64/python3.14/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_executors.py", line 24, in run
    res = await asyncio.gather(*coros)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
___________________ TestIssue39Regr.test_issue39_regression ____________________
Traceback (most recent call last):
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_regr1.py", line 114, in test_issue39_regression
    self.run_test()
    ~~~~~~~~~~~~~^^
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_regr1.py", line 93, in run_test
    addr = qout.get()
  File "/usr/lib64/python3.14/multiprocessing/queues.py", line 101, in get
    res = self._recv_bytes()
  File "/usr/lib64/python3.14/multiprocessing/connection.py", line 222, in recv_bytes
    buf = self._recv_bytes(maxlength)
  File "/usr/lib64/python3.14/multiprocessing/connection.py", line 437, in _recv_bytes
    buf = self._recv(4)
  File "/usr/lib64/python3.14/multiprocessing/connection.py", line 402, in _recv
    chunk = read(handle, to_read)
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_regr1.py", line 74, in on_alarm
    raise FailedTestError
tests.test_regr1.FailedTestError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.14/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib64/python3.14/unittest/case.py", line 660, in run
    self._callTestMethod(testMethod)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib64/python3.14/unittest/case.py", line 606, in _callTestMethod
    result = method()
  File "/builddir/build/BUILD/python-uvloop-0.21.0-build/uvloop-0.21.0/_empty/tests/test_regr1.py", line 116, in test_issue39_regression
    self.fail('deadlocked in libuv')
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/unittest/case.py", line 741, in fail
    raise self.failureException(msg)
AssertionError: deadlocked in libuv

hroncok avatar Mar 12 '25 13:03 hroncok

@hroncok #662 should help with one of the failures there.

cjwatson avatar Apr 16 '25 10:04 cjwatson

@hroncok I have been looking at your work rather closely since I am the maintainer of the windows branch since I am trying to get caught up with some of these changes being made here and I was wondering if maybe migrating to using AbstractEventLoop would be a good solution and then making some form a deprecation warning that discourages the usage of event-loop-policies.

Vizonex avatar May 20 '25 15:05 Vizonex

Any update on this? Now that 3.14 is out it would be nice to get things working.

Ahajha avatar Oct 08 '25 04:10 Ahajha

+1 also blocked on the upgrade because of this

michaelgmiller1 avatar Oct 09 '25 23:10 michaelgmiller1

Hi, thanks so much for the fix, however on pypi there is still no 0.22.0 release (as well github releases).

tajchert avatar Oct 12 '25 22:10 tajchert

Hi, thanks so much for the fix, however on pypi there is still no 0.22.0 release (as well github releases).

@tajchert it hasn't been published yet, see https://github.com/MagicStack/uvloop/pull/692

edgarrmondragon avatar Oct 13 '25 03:10 edgarrmondragon