Skip to content

Commit ac8cf87

Browse files
committed
Make the test more robust
1 parent 99040b6 commit ac8cf87

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_threading.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,14 @@ def catch_exception():
445445
self.assertEqual(result, 1)
446446

447447
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
448-
signal.pthread_kill(thread.ident, signal.SIGUSR1)
449448
if not thread.is_alive():
450449
break
450+
try:
451+
signal.pthread_kill(thread.ident, signal.SIGUSR1)
452+
except OSError:
453+
# The thread might have terminated between the is_alive check
454+
# and the pthread_kill
455+
break
451456

452457
thread.join()
453458
signal.signal(signal.SIGUSR1, signal.SIG_DFL)

0 commit comments

Comments
 (0)