Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_concurrent_futures: test_as_completed.test_future_times_out() fails on GHA Windows x86 CI #109565

Closed
vstinner opened this issue Sep 19, 2023 · 4 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

vstinner commented Sep 19, 2023

Windows x86:

FAIL: test_future_times_out (test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_future_times_out) [0.01]
Test ``futures.as_completed`` timing out before
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\cpython\cpython\Lib\test\test_concurrent_futures\test_as_completed.py", line 60, in test_future_times_out
    self.assertEqual(completed_futures, already_completed)
AssertionError: Items in the first set but not the second:
<Future at 0x5684560 state=finished returned NoneType>

build: https://github.com/python/cpython/actions/runs/6225761937/job/16896880945?pr=108965

The test fails randomly. It passed when re-run in verbose mode in a fresh process:

0:16:02 load avg: 5.55 [2/2/1] test.test_concurrent_futures.test_as_completed passed
Re-running test.test_concurrent_futures.test_as_completed in verbose mode (matching: test_future_times_out)
test_future_times_out (test.test_concurrent_futures.test_as_completed.ProcessPoolForkAsCompletedTest.test_future_times_out)
Test ``futures.as_completed`` timing out before ... skipped 'require unix system'
test_future_times_out (test.test_concurrent_futures.test_as_completed.ProcessPoolForkserverAsCompletedTest.test_future_times_out)
Test ``futures.as_completed`` timing out before ... skipped 'require unix system'
test_future_times_out (test.test_concurrent_futures.test_as_completed.ProcessPoolSpawnAsCompletedTest.test_future_times_out)
Test ``futures.as_completed`` timing out before ... 0.75s ok
test_future_times_out (test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_future_times_out)
Test ``futures.as_completed`` timing out before ... 0.11s ok

----------------------------------------------------------------------
Ran 4 tests in 0.881s

OK (skipped=2)

Linked PRs

@vstinner vstinner added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Sep 19, 2023
@vstinner
Copy link
Member Author

Test also failed on s390x Fedora 3.x: https://buildbot.python.org/all/#/builders/223/builds/4511

  test_future_times_out (test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_future_times_out) [0]
Test ``futures.as_completed`` timing out before ... FAIL

Stdout:
0.35s 
test_no_timeout (test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_no_timeout) ... ok

======================================================================
FAIL: test_future_times_out (test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_future_times_out) [0]
Test ``futures.as_completed`` timing out before
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z/build/Lib/test/test_concurrent_futures/test_as_completed.py", line 60, in test_future_times_out
    self.assertEqual(completed_futures, already_completed)
AssertionError: Items in the first set but not the second:
<Future at 0x3ff9280f1c0 state=finished returned NoneType>

@elfstrom
Copy link
Contributor

I guess this would fix it:

            with self.subTest(timeout):

-               future = self.executor.submit(time.sleep, 0.1)
+               future = self.executor.submit(time.sleep, 10.0)
                completed_futures = set()
                try:

I don't think the short sleep serves any testing purpose here, it just makes the test more likely to fail if there is any unexpected CPU contention.

@vstinner
Copy link
Member Author

The problem is that the test waits cleanly until the future completes, and so the test takes 10 seconds with your change, instead of 100 ms (100x slower).

vstinner added a commit to vstinner/cpython that referenced this issue Sep 27, 2023
as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
vstinner added a commit to vstinner/cpython that referenced this issue Sep 27, 2023
as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
@vstinner
Copy link
Member Author

I proposed PR #109949 to fix this test.

vstinner added a commit that referenced this issue Sep 27, 2023
as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 27, 2023
…onGH-109949)

as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
(cherry picked from commit b1aebf1)

Co-authored-by: Victor Stinner <[email protected]>
csm10495 pushed a commit to csm10495/cpython that referenced this issue Sep 28, 2023
…on#109949)

as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
Yhg1s pushed a commit that referenced this issue Oct 2, 2023
…109949) (#109952)

gh-109565: Fix concurrent.futures test_future_times_out() (GH-109949)

as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
(cherry picked from commit b1aebf1)

Co-authored-by: Victor Stinner <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…on#109949)

as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants