You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_threading: EventTests.test_set_and_clear times out on a busy machine #158336
test_set_and_clear in Lib/test/lock_tests.py starts five threads that call event.wait(), sleeps for 50 ms (wait_threads_blocked()), and then calls event.set() and event.clear(). If a thread only reaches wait() after clear(), it sees the flag unset and waits for LONG_TIMEOUT, so Bunch.__exit__ gives up after SHORT_TIMEOUT:
FAIL: test_set_and_clear (test.test_threading.EventTests.test_set_and_clear)
Traceback (most recent call last):
File "Lib/test/lock_tests.py", line 574, in test_set_and_clear
with Bunch(f, N):
File "Lib/test/lock_tests.py", line 77, in __exit__
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
...
AssertionError: timeout (30.3 seconds)
It reproduces on a free-threaded debug build with TSan (--with-thread-sanitizer --with-pydebug --disable-gil) when the test shares two CPUs with four busy-looping processes:
for i in 1 2 3 4; do taskset --cpu-list 12-13 python3 -c "while True: pass" & done
taskset --cpu-list 12-13 ./python -m test test_threading --match test_set_and_clear
The test failed in 9 of 40 runs. In a copy of the test that counts event._cond._waiters just before set(), every failure had a thread that had not yet started waiting; none was a lost wakeup.
Activity
StanFromIreland commentedon Sep 28, 2026
Previously reported #129266 (comment).