MagicStack / uvloop

Ultra fast asyncio event loop.
Apache License 2.0
10.45k stars 548 forks source link

Add support for Python 3.12 to Uvloop #547

Closed gotmax23 closed 1 year ago

gotmax23 commented 1 year ago

Uvloop's test suite currently fails on Python 3.12:

======================================================================
ERROR: test_aiohttp_graceful_shutdown (tests.test_aiohttp.Test_AIO_AioHTTP.test_aiohttp_graceful_shutdown)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/asyncio/tasks.py", line 510, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/aiohttp/web_runner.py", line 293, in cleanup
    await site.stop()
  File "/usr/lib64/python3.12/site-packages/aiohttp/web_runner.py", line 75, in stop
    await self._server.wait_closed()
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 384, in wait_closed
    await waiter
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_aiohttp.py", line 101, in test_aiohttp_graceful_shutdown
    self.loop.run_until_complete(stop())
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_aiohttp.py", line 93, in stop
    await asyncio.wait_for(runner.cleanup(), timeout=0.1)
  File "/usr/lib64/python3.12/asyncio/tasks.py", line 509, in wait_for
    async with timeouts.timeout(timeout):
  File "/usr/lib64/python3.12/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError
======================================================================
ERROR: test_libuv_get_loop_t_ptr (tests.test_libuv_api.Test_UV_libuv.test_libuv_get_loop_t_ptr)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_libuv_api.py", line 12, in test_libuv_get_loop_t_ptr
    import pyximport
  File "/usr/lib64/python3.12/site-packages/pyximport/__init__.py", line 1, in <module>
    from .pyximport import *
  File "/usr/lib64/python3.12/site-packages/pyximport/pyximport.py", line 51, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'
======================================================================
ERROR: test_process_double_close (tests.test_process.Test_UV_Process.test_process_double_close)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_process.py", line 867, in test_process_double_close
    subprocess.run([sys.executable, '-c', script], check=True)
  File "/usr/lib64/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', '\nimport os\nimport sys\nfrom unittest import mock\n\nimport asyncio\n\npipes = []\noriginal_os_pipe = os.pipe\ndef log_pipes():\n    pipe = original_os_pipe()\n    pipes.append(pipe)\n    return pipe\n\ndups = []\noriginal_os_dup = os.dup\ndef log_dups(*args, **kwargs):\n    dup = original_os_dup(*args, **kwargs)\n    dups.append(dup)\n    return dup\n\nwith mock.patch(\n    "os.close", wraps=os.close\n) as os_close, mock.patch(\n    "os.pipe", new=log_pipes\n), mock.patch(\n    "os.dup", new=log_dups\n):\n    import uvloop\n\n\nasync def test():\n    proc = await asyncio.create_subprocess_exec(\n        sys.executable, "-c", "pass"\n    )\n    await proc.communicate()\n\nuvloop.install()\nasyncio.run(test())\n\nstdin, stdout, stderr = dups\n(r, w), = pipes\nassert os_close.mock_calls == [\n    mock.call(w),\n    mock.call(r),\n    mock.call(stderr),\n    mock.call(stdout),\n    mock.call(stdin),\n]\n']' returned non-zero exit status 1.
======================================================================
FAIL: test_create_server_1 (tests.test_tcp.Test_AIO_TCP.test_create_server_1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_tcp.py", line 177, in test_create_server_1
    self.loop.run_until_complete(start_server())
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_tcp.py", line 138, in start_server
    self.assertEqual(srv_sock.fileno(), -1)
AssertionError: 29 != -1
======================================================================
FAIL: test_create_server_3 (tests.test_tcp.Test_AIO_TCP.test_create_server_3)
check ephemeral port can be used
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_tcp.py", line 214, in test_create_server_3
    self.loop.run_until_complete(start_server_ephemeral_ports())
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_tcp.py", line 210, in start_server_ephemeral_ports
    self.assertEqual(srv_sock.fileno(), -1)
AssertionError: 29 != -1
======================================================================
FAIL: test_create_unix_server_1 (tests.test_unix.Test_AIO_Unix.test_create_unix_server_1) (func='start_unix_server(host, port)')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_unix.py", line 129, in test_create_unix_server_1
    self.loop.run_until_complete(start_server())
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_unix.py", line 86, in start_server
    self.assertEqual(srv_sock.fileno(), -1)
AssertionError: 29 != -1
======================================================================
FAIL: test_create_unix_server_1 (tests.test_unix.Test_AIO_Unix.test_create_unix_server_1) (func='start_unix_server(sock)')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_unix.py", line 133, in test_create_unix_server_1
    self.loop.run_until_complete(start_server_sock(
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_unix.py", line 121, in start_server_sock
    self.assertEqual(srv_sock.fileno(), -1)
AssertionError: 29 != -1
======================================================================
FAIL: test_create_unix_server_1 (tests.test_unix.Test_AIO_Unix.test_create_unix_server_1) (func='start_server(sock)')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_unix.py", line 141, in test_create_unix_server_1
    self.loop.run_until_complete(start_server_sock(
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/uvloop-0.17.0/tests/test_unix.py", line 121, in start_server_sock
    self.assertEqual(srv_sock.fileno(), -1)
AssertionError: 29 != -1
----------------------------------------------------------------------
Ran 506 tests in 121.799s
FAILED (failures=5, errors=3, skipped=33)
Test failed: <unittest.runner.TextTestResult run=506 errors=3 failures=5>
error: Test failed: <unittest.runner.TextTestResult run=506 errors=3 failures=5>

Please add Python 3.12 support.

fantix commented 1 year ago

Added in #570 and uvloop 0.18