dabeaz / curio

Good Curio!
Other
4.04k stars 244 forks source link

test_cpu failure with python 3.12 #368

Open ncopa opened 8 months ago

ncopa commented 8 months ago
================================================================================= FAILURES =================================================================================
_________________________________________________________________________________ test_cpu _________________________________________________________________________________

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

    def test_cpu(kernel):                                                                                                                                                   
        results = []                       

        async def spin(n):                                                                                                                                                  
            while n > 0:                                                              
                results.append(n)    
                await sleep(0.1)      
                n -= 1                                                                                                                                                      

        async def cpu_bound(n):                                                       
            r = await run_in_process(fib, n)                           
            results.append(('fib', r))

        async def main():
            async with TaskGroup() as g:
                await g.spawn(spin, 10)
                await g.spawn(cpu_bound, 36)

        kernel.run(main())

>       assert results == [
            10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
            ('fib', 14930352)
        ]
E       AssertionError: assert [10, 9, 8, 7, 6, 5, ...] == [10, 9, 8, 7, 6, 5, ...]
E         
E         At index 7 diff: ('fib', 14930352) != 3
E         
E         Full diff:
E           [
E               10,
E               9,...
E         
E         ...Full output truncated (16 lines hidden), use '-vv' to show

tests/test_workers.py:38: AssertionError
============================================================================= warnings summary =============================================================================
build/lib/curio/monitor.py:58
  /home/ncopa/aports/community/py3-curio/src/curio-1.6/build/lib/curio/monitor.py:58: DeprecationWarning: 'telnetlib' is deprecated and slated for removal in Python 3.13
    import telnetlib

tests/test_file.py::test_sync_with
  /home/ncopa/aports/community/py3-curio/src/curio-1.6/tests/test_file.py:224: RuntimeWarning: coroutine 'AsyncFile.__aenter__' was never awaited
    assert True
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_io.py::test_stream_bad_context
  /home/ncopa/aports/community/py3-curio/src/curio-1.6/tests/test_io.py:850: RuntimeWarning: coroutine 'StreamBase.__aenter__' was never awaited
    results.append(True)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_io.py::test_stream_bad_iter
  /home/ncopa/aports/community/py3-curio/src/curio-1.6/tests/test_io.py:883: RuntimeWarning: coroutine 'StreamBase.__anext__' was never awaited
    results.append(True)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_kernel.py::test_reentrant_kernel 
  /home/ncopa/aports/community/py3-curio/src/curio-1.6/tests/test_kernel.py:726: RuntimeWarning: coroutine 'test_reentrant_kernel.<locals>.child' was never awaited
    with pytest.raises(RuntimeError):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_kernel.py::test_kernel_no_shutdown
  /usr/lib/python3.12/site-packages/_pytest/unraisableexception.py:80: PytestUnraisableExceptionWarning: Exception ignored in: <function Kernel.__del__ at 0x7f7cbaa39d00>

  Traceback (most recent call last):
    File "/home/ncopa/aports/community/py3-curio/src/curio-1.6/build/lib/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
  /usr/lib/python3.12/site-packages/_pytest/python.py:195: RuntimeWarning: coroutine 'test_instantiate_coroutine.<locals>.coro' was never awaited
    result = testfunction(**testargs)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_meta.py::test_missing_asynccontextmanager
  /usr/lib/python3.12/site-packages/_pytest/unraisableexception.py:80: PytestUnraisableExceptionWarning: Exception ignored in: <async_generator object test_missing_asynccon
textmanager.<locals>.manager at 0x7f7cbaac8120>

  Traceback (most recent call last):
    File "/home/ncopa/aports/community/py3-curio/src/curio-1.6/build/lib/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_thread.py::test_errors
  /home/ncopa/aports/community/py3-curio/src/curio-1.6/tests/test_thread.py:266: RuntimeWarning: coroutine 'simple_coro' was never awaited
    with pytest.raises(AsyncOnlyError):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
FAILED tests/test_workers.py::test_cpu - AssertionError: assert [10, 9, 8, 7, 6, 5, ...] == [10, 9, 8, 7, 6, 5, ...]
============================================== 1 failed, 256 passed, 4 skipped, 2 deselected, 9 warnings in 627.78s (0:10:27) ==============================================
>
ncopa commented 8 months ago

Actually, this also happens with python 3.11. Might be related pytest 8 upgrade.

dabeaz commented 7 months ago

I'm using pytest 8.1.1 on MacOS and don't see this failure. However, I won't rule out the possibility of the test itself being kind of flaky. I'll take a look.

skeuchel commented 7 months ago

This might be related to a binutils bump from 2.41 to 2.42.