]> granicus.if.org Git - python/commitdiff
Issue #8407: Fix pthread_sigmask() tests on Mac OS X
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 3 May 2011 12:11:22 +0000 (14:11 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 3 May 2011 12:11:22 +0000 (14:11 +0200)
Disable faulthandler timeout thread on Mac OS X: it interacts with
pthread_sigmask() tests.

Lib/test/test_signal.py

index 809da3a8b65dc0614eeb4b1eb40c6ceb4bffa67a..5caf13d8d6c7a44ae3f3dc51dbae9004b17e28cb 100644 (file)
@@ -504,6 +504,21 @@ class PthreadSigmaskTests(unittest.TestCase):
         def read_sigmask():
             return signal.pthread_sigmask(signal.SIG_BLOCK, [])
 
+        if sys.platform == "darwin":
+            import faulthandler
+            # The fault handler timeout thread masks all signals. If the main
+            # thread masks also SIGUSR1, all threads mask this signal. In this
+            # case, on Mac OS X, if we send SIGUSR1 to the process, the signal
+            # is pending in the main or the faulthandler timeout thread.
+            # Unblock SIGUSR1 in the main thread calls the signal handler only
+            # if the signal is pending for the main thread.
+            #
+            # Stop the faulthandler timeout thread to workaround this problem.
+            # Another solution would be to send the signal directly to the main
+            # thread using pthread_kill(), but Python doesn't expose this
+            # function.
+            faulthandler.cancel_dump_tracebacks_later()
+
         old_handler = signal.signal(signum, handler)
         self.addCleanup(signal.signal, signum, old_handler)