Skip to content

Commit d297fc5

Browse files
committed
Don't abort the barrier when the double-clear test passes
The test aborted its barrier in a finally block, so on success it could break the last round while the workers were still waking from it. They then raised BrokenBarrierError, which regrtest reports as an uncaught thread exception, failing the free-threaded CI jobs under --fail-env-changed. Abort only when the main loop fails, and let the workers return if the barrier is broken.
1 parent 56c8877 commit d297fc5

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎Lib/test/test_free_threading/test_context_watcher.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ def worker(k):
7070
successes[k] += 1
7171
except ValueError:
7272
pass
73-
done.wait(support.SHORT_TIMEOUT)
73+
try:
74+
done.wait(support.SHORT_TIMEOUT)
75+
except threading.BrokenBarrierError:
76+
return
7477

7578
threads = [threading.Thread(target=worker, args=(k,))
7679
for k in range(NTHREADS)]
@@ -82,8 +85,10 @@ def worker(k):
8285
round_no = r
8386
done.wait(support.SHORT_TIMEOUT)
8487
self.assertEqual(sum(successes) - before, 1)
85-
finally:
88+
except BaseException:
89+
# Release the workers so that start_threads() can join them.
8690
done.abort()
91+
raise
8792

8893
def test_clear_watcher_races_notification(self):
8994
"""Race ClearWatcher against notification.

0 commit comments

Comments
 (0)