Commit f44ce874 authored by Victor Stinner's avatar Victor Stinner

Issue #8407: disable faulthandler timeout thread on all platforms

The problem is not specific to Mac OS X.
parent 441f9352
...@@ -494,6 +494,7 @@ class PthreadSigmaskTests(unittest.TestCase): ...@@ -494,6 +494,7 @@ class PthreadSigmaskTests(unittest.TestCase):
self.assertRaises(RuntimeError, signal.pthread_sigmask, 1700, []) self.assertRaises(RuntimeError, signal.pthread_sigmask, 1700, [])
def test_block_unlock(self): def test_block_unlock(self):
import faulthandler
pid = os.getpid() pid = os.getpid()
signum = signal.SIGUSR1 signum = signal.SIGUSR1
...@@ -503,20 +504,18 @@ class PthreadSigmaskTests(unittest.TestCase): ...@@ -503,20 +504,18 @@ class PthreadSigmaskTests(unittest.TestCase):
def read_sigmask(): def read_sigmask():
return signal.pthread_sigmask(signal.SIG_BLOCK, []) return signal.pthread_sigmask(signal.SIG_BLOCK, [])
if sys.platform == "darwin": # The fault handler timeout thread masks all signals. If the main
import faulthandler # thread masks also SIGUSR1, all threads mask this signal. In this
# The fault handler timeout thread masks all signals. If the main # case, if we send SIGUSR1 to the process, the signal is pending in the
# thread masks also SIGUSR1, all threads mask this signal. In this # main or the faulthandler timeout thread. Unblock SIGUSR1 in the main
# case, on Mac OS X, if we send SIGUSR1 to the process, the signal # thread calls the signal handler only if the signal is pending for the
# is pending in the main or the faulthandler timeout thread. # main 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
# Stop the faulthandler timeout thread to workaround this problem. # thread using pthread_kill(), but Python doesn't expose this
# Another solution would be to send the signal directly to the main # function.
# thread using pthread_kill(), but Python doesn't expose this faulthandler.cancel_dump_tracebacks_later()
# function.
faulthandler.cancel_dump_tracebacks_later()
# Install our signal handler # Install our signal handler
old_handler = signal.signal(signum, handler) old_handler = signal.signal(signum, handler)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment