Skip to content

test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_timeout flakes frequently on free-threaded Windows x64 #128364

@zanieb

Description

@zanieb

Bug report

Bug description:

The following test fails frequently, but not consistently:

test_timeout (test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_timeout) ... FAIL
0.86s 
======================================================================
FAIL: test_timeout (test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_timeout)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\cpython\cpython\Lib\test\test_concurrent_futures\test_wait.py", line 129, in test_timeout
    self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                          EXCEPTION_FUTURE,
                          ^^^^^^^^^^^^^^^^^
                          SUCCESSFUL_FUTURE]),
                          ^^^^^^^^^^^^^^^^^^^^
                     finished)
                     ^^^^^^^^^
AssertionError: Items in the second set but not the first:
<Future at 0x20000554620 state=finished returned NoneType>

As seen in the following CI runs for recent commits to main

A brief analysis of the code at

def test_timeout(self):
short_timeout = 0.050
long_timeout = short_timeout * 10
future = self.executor.submit(time.sleep, long_timeout)
finished, pending = futures.wait(
[CANCELLED_AND_NOTIFIED_FUTURE,
EXCEPTION_FUTURE,
SUCCESSFUL_FUTURE,
future],
timeout=short_timeout,
return_when=futures.ALL_COMPLETED)
self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
EXCEPTION_FUTURE,
SUCCESSFUL_FUTURE]),
finished)
self.assertEqual(set([future]), pending)

looks like the sleeping future is present in the finished set instead of pending

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions