mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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).
This commit is contained in:
parent
4467d2c3ac
commit
a376a72bd9
1 changed files with 2 additions and 1 deletions
|
@ -286,11 +286,12 @@ class ExecutorDeadlockTest:
|
|||
super().wakeup()
|
||||
|
||||
def clear(self):
|
||||
super().clear()
|
||||
try:
|
||||
while True:
|
||||
self._dummy_queue.get_nowait()
|
||||
except queue.Empty:
|
||||
super().clear()
|
||||
pass
|
||||
|
||||
with (unittest.mock.patch.object(futures.process._ExecutorManagerThread,
|
||||
'run', mock_run),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue