Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[3.11] gh-109974: Fix threading lock_tests race conditions (GH-110057)#110063

Closed
miss-islington wants to merge 1 commit into
python:3.11python/cpython:3.11from
miss-islington:backport-4e356ad-3.11miss-islington/cpython:backport-4e356ad-3.11Copy head branch name to clipboard
Closed

[3.11] gh-109974: Fix threading lock_tests race conditions (GH-110057)#110063
miss-islington wants to merge 1 commit into
python:3.11python/cpython:3.11from
miss-islington:backport-4e356ad-3.11miss-islington/cpython:backport-4e356ad-3.11Copy head branch name to clipboard

Conversation

@miss-islington

@miss-islington miss-islington commented Sep 29, 2023

Copy link
Copy Markdown
Contributor

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)

Co-authored-by: Victor Stinner vstinner@python.org

…10057)

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)

Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner

Copy link
Copy Markdown
Member

Oh, tests fail with:

AttributeError: module 'test.support' has no attribute 'sleeping_retry'

I will wait until changes are backported to 3.12 to backport these changes properly to 3.11.

@vstinner vstinner closed this Sep 29, 2023
auto-merge was automatically disabled September 29, 2023 12:30

Pull request was closed

@miss-islington miss-islington deleted the backport-4e356ad-3.11 branch September 29, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.