]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650) (#110658)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 11 Oct 2023 00:26:48 +0000 (02:26 +0200)
committerGitHub <noreply@github.com>
Wed, 11 Oct 2023 00:26:48 +0000 (00:26 +0000)
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 e07c37cd5212c9d13749b4d02a1d68e1efcba6cf)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_signal.py
Misc/NEWS.d/next/Tests/2023-10-10-23-20-13.gh-issue-110647.jKG3sY.rst [new file with mode: 0644]

index 2a1a1ee22f43dac0a5d04787199011db29b09ed1..f2ae28c38dd72d721a8319e536f46b2882af0c2f 100644 (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()
diff --git a/Misc/NEWS.d/next/Tests/2023-10-10-23-20-13.gh-issue-110647.jKG3sY.rst b/Misc/NEWS.d/next/Tests/2023-10-10-23-20-13.gh-issue-110647.jKG3sY.rst
new file mode 100644 (file)
index 0000000..00f38c8
--- /dev/null
@@ -0,0 +1,2 @@
+Fix test_stress_modifying_handlers() of test_signal. Patch by Victor
+Stinner.