[3.12] gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650) (#110658)

gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650)

* cycle_handlers() now waits until at least one signal is received.
* num_received_signals can be equal to num_sent_signals.
(cherry picked from commit e07c37cd52)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2023-10-11 02:26:48 +02:00 committed by GitHub
parent c2d542b42c
commit dcd47e506d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -1339,7 +1339,7 @@ class StressTest(unittest.TestCase):
num_sent_signals += 1
def cycle_handlers():
while num_sent_signals < 100:
while num_sent_signals < 100 or num_received_signals < 1:
for i in range(20000):
# Cycle between a Python-defined and a non-Python handler
for handler in [custom_handler, signal.SIG_IGN]:
@ -1372,7 +1372,7 @@ class StressTest(unittest.TestCase):
if not ignored:
# Sanity check that some signals were received, but not all
self.assertGreater(num_received_signals, 0)
self.assertLess(num_received_signals, num_sent_signals)
self.assertLessEqual(num_received_signals, num_sent_signals)
finally:
do_stop = True
t.join()

View file

@ -0,0 +1,2 @@
Fix test_stress_modifying_handlers() of test_signal. Patch by Victor
Stinner.