Skip to content

Commit a376a72

Browse files
authored
gh-109917: Fix test instability in test_concurrent_futures (#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).
1 parent 4467d2c commit a376a72

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
@@ -286,11 +286,12 @@ def wakeup(self):
286286
super().wakeup()
287287

288288
def clear(self):
289+
super().clear()
289290
try:
290291
while True:
291292
self._dummy_queue.get_nowait()
292293
except queue.Empty:
293-
super().clear()
294+
pass
294295

295296
with (unittest.mock.patch.object(futures.process._ExecutorManagerThread,
296297
'run', mock_run),

0 commit comments

Comments
 (0)