Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commented Sep 29, 2023

  • Add context manager on Bunch class.
  • Bunch now catchs exceptions on executed functions and re-raise them at exit() as an ExceptionGroup.
  • Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds.
  • test_with(): inline _with() function.

* Add context manager on Bunch class. * Bunch now catchs exceptions on executed functions and re-raise them at __exit__() as an ExceptionGroup. * Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds. * test_with(): inline _with() function.
@vstinner
Copy link
MemberAuthor

Windows x64 failed with:

 0:22:17 load avg: 0.08 [467/467/1] test.test_concurrent_futures.test_shutdown process crashed (Exit code 1) Timeout (0:10:00)! Thread 0x00001b44 (most recent call first): File "D:\a\cpython\cpython\Lib\subprocess.py", line 1597 in _readerthread File "D:\a\cpython\cpython\Lib\threading.py", line 1003 in run File "D:\a\cpython\cpython\Lib\threading.py", line 1066 in _bootstrap_inner File "D:\a\cpython\cpython\Lib\threading.py", line 1023 in _bootstrap Thread 0x00000e08 (most recent call first): File "D:\a\cpython\cpython\Lib\subprocess.py", line 1597 in _readerthread File "D:\a\cpython\cpython\Lib\threading.py", line 1003 in run File "D:\a\cpython\cpython\Lib\threading.py", line 1066 in _bootstrap_inner File "D:\a\cpython\cpython\Lib\threading.py", line 1023 in _bootstrap Thread 0x00001a48 (most recent call first): File "D:\a\cpython\cpython\Lib\threading.py", line 1160 in _wait_for_tstate_lock File "D:\a\cpython\cpython\Lib\threading.py", line 1140 in join File "D:\a\cpython\cpython\Lib\subprocess.py", line 1626 in _communicate File "D:\a\cpython\cpython\Lib\subprocess.py", line 1209 in communicate File "D:\a\cpython\cpython\Lib\test\support\script_helper.py", line 139 in run_python_until_end File "D:\a\cpython\cpython\Lib\test\support\script_helper.py", line 149 in _assert_python File "D:\a\cpython\cpython\Lib\test\support\script_helper.py", line 166 in assert_python_ok File "D:\a\cpython\cpython\Lib\test\test_concurrent_futures\test_shutdown.py", line 32 in test_interpreter_shutdown 

@vstinner
Copy link
MemberAuthor

Windows x64 failed with: FAIL: test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_started (test.test_asyncio.test_waitfor.AsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_started).

Good news: PR #110092 is going to fix it.

@vstinnervstinner merged commit 743e357 into python:mainSep 29, 2023
@vstinnervstinner deleted the lock_tests2 branch September 29, 2023 12:21
vstinner added a commit to vstinner/cpython that referenced this pull request Oct 4, 2023
…n#110089) * Add context manager on Bunch class. * Bunch now catchs exceptions on executed functions and re-raise them at __exit__() as an ExceptionGroup. * Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds. * test_with(): inline _with() function. (cherry picked from commit 743e357)
vstinner added a commit that referenced this pull request Oct 4, 2023
…110346) * gh-109974: Fix threading lock_tests race conditions (#110057) Fix race conditions in test_threading lock tests. Wait until a condition is met rather than using time.sleep() with a hardcoded number of seconds. * Replace sleeping loops with support.sleeping_retry() which raises an exception on timeout. * Add wait_threads_blocked(nthread) which computes a sleep depending on the number of threads. Remove _wait() function. * test_set_and_clear(): use a way longer Event.wait() timeout. * BarrierTests.test_repr(): wait until the 2 threads are waiting for the barrier. Use a way longer timeout for Barrier.wait() timeout. * test_thread_leak() no longer needs to count len(threading.enumerate()): Bunch uses threading_helper.wait_threads_exit() internally which does it in wait_for_finished(). * Add BaseLockTests.wait_phase() which implements a timeout. test_reacquire() and test_recursion_count() use wait_phase(). (cherry picked from commit 4e356ad) * gh-109974: Fix more threading lock_tests race conditions (#110089) * Add context manager on Bunch class. * Bunch now catchs exceptions on executed functions and re-raise them at __exit__() as an ExceptionGroup. * Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds. * test_with(): inline _with() function. (cherry picked from commit 743e357)
vstinner added a commit that referenced this pull request Oct 4, 2023
…110355) [3.12] gh-109974: Fix threading lock_tests race conditions (#110057) (#110346) * gh-109974: Fix threading lock_tests race conditions (#110057) Fix race conditions in test_threading lock tests. Wait until a condition is met rather than using time.sleep() with a hardcoded number of seconds. * Replace sleeping loops with support.sleeping_retry() which raises an exception on timeout. * Add wait_threads_blocked(nthread) which computes a sleep depending on the number of threads. Remove _wait() function. * test_set_and_clear(): use a way longer Event.wait() timeout. * BarrierTests.test_repr(): wait until the 2 threads are waiting for the barrier. Use a way longer timeout for Barrier.wait() timeout. * test_thread_leak() no longer needs to count len(threading.enumerate()): Bunch uses threading_helper.wait_threads_exit() internally which does it in wait_for_finished(). * Add BaseLockTests.wait_phase() which implements a timeout. test_reacquire() and test_recursion_count() use wait_phase(). (cherry picked from commit 4e356ad) * gh-109974: Fix more threading lock_tests race conditions (#110089) * Add context manager on Bunch class. * Bunch now catchs exceptions on executed functions and re-raise them at __exit__() as an ExceptionGroup. * Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds. * test_with(): inline _with() function. (cherry picked from commit 743e357) (cherry picked from commit 1d032ea)
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…n#110089) * Add context manager on Bunch class. * Bunch now catchs exceptions on executed functions and re-raise them at __exit__() as an ExceptionGroup. * Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds. * test_with(): inline _with() function.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@vstinner