Skip to content

Commit

Permalink
pythongh-110647: Fix signal test_stress_modifying_handlers() (pythonG…
Browse files Browse the repository at this point in the history
…H-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 e07c37c)

Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
vstinner authored and miss-islington committed Oct 10, 2023
1 parent a009bb8 commit 0cec86e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/test/test_signal.py
Expand Up @@ -1347,7 +1347,7 @@ def set_interrupts():
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]:
Expand Down Expand Up @@ -1380,7 +1380,7 @@ def cycle_handlers():
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()
Expand Down
@@ -0,0 +1,2 @@
Fix test_stress_modifying_handlers() of test_signal. Patch by Victor
Stinner.

0 comments on commit 0cec86e

Please sign in to comment.