Skip to content

Commit 414f562

Browse files
[3.12] gh-109917: Fix test instability in test_concurrent_futures (GH-110306) (#110315)
gh-109917: Fix test instability in test_concurrent_futures (GH-110306) The test had an instability issue due to the ordering of the dummy queue operation and the real wakeup pipe operations. Both primitives are thread safe but not done atomically as a single update and may interleave arbitrarily. With the old order of operations this can lead to an incorrect state where the dummy queue is full but the wakeup pipe is empty. By swapping the order in clear() I think this can no longer happen in any possible operation interleaving (famous last words). (cherry picked from commit a376a72) Co-authored-by: elfstrom <[email protected]>
1 parent 4c0f42b commit 414f562

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/test/test_concurrent_futures/test_deadlock.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,12 @@ def wakeup(self):
284284
super().wakeup()
285285

286286
def clear(self):
287+
super().clear()
287288
try:
288289
while True:
289290
self._dummy_queue.get_nowait()
290291
except queue.Empty:
291-
super().clear()
292+
pass
292293

293294
with (unittest.mock.patch.object(futures.process._ExecutorManagerThread,
294295
'run', mock_run),

0 commit comments

Comments
 (0)