anyio
anyio copied to clipboard
Suspicion of flaky test: test_cancelscope_propagation_when_abandoned
Things to check first
-
[X] I have searched the existing issues and didn't find my bug already reported there
-
[X] I have checked that my bug is still present in the latest release
AnyIO version
4.1.0
Python version
3.10
What happened?
I found a test flakiness/race in:
https://github.com/NixOS/nixpkgs/pull/281858#issuecomment-1908329079
=================================== FAILURES ===================================
______________ test_cancelscope_propagation_when_abandoned[trio] _______________
[gw31] linux -- Python 3.10.13 /nix/store/8np01kr8qpm49m2gzjbwcjr68f162b9x-python3-3.10.13/bin/python3.10
/nix/store/r4mhvx3r2pigizgch91dvx4s7kf10baw-python3.10-pytest-7.4.3/lib/python3.10/site-packages/_pytest/runner.py:341: in from_call
result: Optional[TResult] = func()
/nix/store/r4mhvx3r2pigizgch91dvx4s7kf10baw-python3.10-pytest-7.4.3/lib/python3.10/site-packages/_pytest/runner.py:262: in <lambda>
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
/nix/store/wmx47qf64ymxicnjiw05p2y54r998h5i-python3.10-pluggy-1.3.0/lib/python3.10/site-packages/pluggy/_hooks.py:493: in __call__
return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
/nix/store/wmx47qf64ymxicnjiw05p2y54r998h5i-python3.10-pluggy-1.3.0/lib/python3.10/site-packages/pluggy/_manager.py:115: in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/nix/store/r4mhvx3r2pigizgch91dvx4s7kf10baw-python3.10-pytest-7.4.3/lib/python3.10/site-packages/_pytest/threadexception.py:83: in pytest_runtest_call
yield from thread_exception_runtest_hook()
/nix/store/r4mhvx3r2pigizgch91dvx4s7kf10baw-python3.10-pytest-7.4.3/lib/python3.10/site-packages/_pytest/threadexception.py:73: in thread_exception_runtest_hook
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
E pytest.PytestUnhandledThreadExceptionWarning: Exception in thread AnyIO worker thread
E
E Traceback (most recent call last):
E File "/nix/store/8np01kr8qpm49m2gzjbwcjr68f162b9x-python3-3.10.13/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
E self.run()
E File "/nix/store/1fdn4d018vfn7ygwaiy451iyp9va54nh-python3.10-anyio-4.1.0/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 830, in run
E self.loop.call_soon_threadsafe(
E File "uvloop/loop.pyx", line 1288, in uvloop.loop.Loop.call_soon_threadsafe
E File "uvloop/loop.pyx", line 671, in uvloop.loop.Loop._append_ready_handle
E File "uvloop/loop.pyx", line 703, in uvloop.loop.Loop._check_closed
E RuntimeError: Event loop is closed
Re-running made the test pass.
How can we reproduce the bug?
Unclear, probably run the test often enough?
The error (pointing to uvloop) seems unrelated to the test (which runs on Trio). Most likely this is caused by the abandoned thread from the previous test instance to fail because the event loop has already been closed.
Is this still relevant? I haven't seen this myself.