dabeaz / curio

Good Curio!
Other
4.01k stars 240 forks source link

test_timeout test failure with Python 3.9.9. #347

Open Apteryks opened 2 years ago

Apteryks commented 2 years ago

After upgrading to Python 3.9.9 in Guix, I see the following test failure:

=================================== FAILURES ===================================
_________________________________ test_timeout _________________________________

kernel = <curio.kernel.Kernel object at 0x7ffff603f760>

    def test_timeout(kernel):
        results = []
        async def subproc():
            try:
                async with timeout_after(0.5):
                    out = await subprocess.run([executable, os.path.join(dirname, 'child.py')], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                    results.append('what?')
            except TaskTimeout as e:
                results.append('timeout')
                results.append(e.stdout)
                results.append(e.stderr)

        kernel.run(subproc())
        if sys.platform.startswith('win'):
            assert results == ['timeout', b'', b'']
        else:
>           assert results == ['timeout', b't-minus 4\n', b'']
E           AssertionError: assert ['timeout', b'', b''] == ['timeout', b't-minus 4\n', b'']
E             At index 1 diff: b'' != b't-minus 4\n'
E             Full diff:
E             - ['timeout', b't-minus 4\n', b'']
E             ?               -----------
E             + ['timeout', b'', b'']

tests/test_subprocess.py:84: AssertionError
=============================== warnings summary ===============================
tests/test_file.py::test_sync_with
  /tmp/guix-build-python-curio-1.5.drv-0/curio-1.5/tests/test_file.py:224: RuntimeWarning: coroutine 'AsyncFile.__aenter__' was never awaited
    assert True

tests/test_io.py::test_stream_bad_context
  /tmp/guix-build-python-curio-1.5.drv-0/curio-1.5/tests/test_io.py:850: RuntimeWarning: coroutine 'StreamBase.__aenter__' was never awaited
    results.append(True)

tests/test_io.py::test_stream_bad_iter
  /tmp/guix-build-python-curio-1.5.drv-0/curio-1.5/tests/test_io.py:883: RuntimeWarning: coroutine 'StreamBase.__anext__' was never awaited
    results.append(True)

tests/test_kernel.py::test_reentrant_kernel
  /tmp/guix-build-python-curio-1.5.drv-0/curio-1.5/tests/test_kernel.py:727: RuntimeWarning: coroutine 'test_reentrant_kernel.<locals>.child' was never awaited
    kernel.run(child)

tests/test_kernel.py::test_kernel_no_shutdown
  /gnu/store/s8y6294p2qjykg9k6ac0ch1ngzlm56xl-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <function Kernel.__del__ at 0x7ffff617b9d0>

  Traceback (most recent call last):
    File "/gnu/store/wxm0cqmb11v95ch8mr1y77yfy6r3azxd-python-curio-1.5/lib/python3.9/site-packages/curio/kernel.py", line 116, in __del__
      raise RuntimeError(
  RuntimeError: Curio kernel not properly terminated.  Please use Kernel.run(shutdown=True)

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_meta.py::test_instantiate_coroutine
  /gnu/store/s8y6294p2qjykg9k6ac0ch1ngzlm56xl-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/python.py:183: RuntimeWarning: coroutine 'test_instantiate_coroutine.<locals>.coro' was never awaited
    result = testfunction(**testargs)

tests/test_meta.py::test_missing_asynccontextmanager
  /gnu/store/s8y6294p2qjykg9k6ac0ch1ngzlm56xl-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object test_missing_asynccontextmanager.<locals>.manager at 0x7ffff6dcadc0>

  Traceback (most recent call last):
    File "/gnu/store/wxm0cqmb11v95ch8mr1y77yfy6r3azxd-python-curio-1.5/lib/python3.9/site-packages/curio/meta.py", line 224, in _fini_async_gen
      raise RuntimeError("Async generator with async finalization must be wrapped by\n"
  RuntimeError: Async generator with async finalization must be wrapped by
  async with curio.meta.finalize(agen) as agen:
      async for n in agen:
           ...
  See PEP 533 for further discussion.

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_network.py::test_tcp_echo
  /gnu/store/s8y6294p2qjykg9k6ac0ch1ngzlm56xl-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <function Task.__del__ at 0x7ffff6246f70>

  Traceback (most recent call last):
    File "/gnu/store/wxm0cqmb11v95ch8mr1y77yfy6r3azxd-python-curio-1.5/lib/python3.9/site-packages/curio/task.py", line 157, in __del__
      if not self.daemon and not self.exception:
    File "/gnu/store/wxm0cqmb11v95ch8mr1y77yfy6r3azxd-python-curio-1.5/lib/python3.9/site-packages/curio/task.py", line 222, in exception
      raise RuntimeError('Task not terminated')
  RuntimeError: Task not terminated

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_thread.py::test_errors
  /tmp/guix-build-python-curio-1.5.drv-0/curio-1.5/tests/test_thread.py:267: RuntimeWarning: coroutine 'simple_coro' was never awaited
    AWAIT(simple_coro(2,3))

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/test_subprocess.py::test_timeout - AssertionError: assert ['time...
= 1 failed, 256 passed, 4 skipped, 1 deselected, 9 warnings in 107.49s (0:01:47) =
error: in phase 'check': uncaught exception:
%exception #<&invoke-error program: "pytest" arguments: ("-vv" "-k" "not test_ssl_outgoing") exit-status: 1 term-signal: #f stop-signal: #f> 
phase `check' failed after 108.4 seconds
command "pytest" "-vv" "-k" "not test_ssl_outgoing" failed with status 1

The build was succeeding with Python 3.9.6 (see: https://ci.guix.gnu.org/build/68233/details).