aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 80b08b8ac66..38a03f3391d 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -6045,6 +6045,27 @@ class TestResourceTracker(unittest.TestCase):
cleanup=cleanup,
)
+ @unittest.skipUnless(hasattr(signal, "pthread_sigmask"), "pthread_sigmask is not available")
+ def test_resource_tracker_blocked_signals(self):
+ #
+ # gh-127586: Check that resource_tracker does not override blocked signals of caller.
+ #
+ from multiprocessing.resource_tracker import ResourceTracker
+ orig_sigmask = signal.pthread_sigmask(signal.SIG_BLOCK, set())
+ signals = {signal.SIGTERM, signal.SIGINT, signal.SIGUSR1}
+
+ try:
+ for sig in signals:
+ signal.pthread_sigmask(signal.SIG_SETMASK, {sig})
+ self.assertEqual(signal.pthread_sigmask(signal.SIG_BLOCK, set()), {sig})
+ tracker = ResourceTracker()
+ tracker.ensure_running()
+ self.assertEqual(signal.pthread_sigmask(signal.SIG_BLOCK, set()), {sig})
+ tracker._stop()
+ finally:
+ # restore sigmask to what it was before executing test
+ signal.pthread_sigmask(signal.SIG_SETMASK, orig_sigmask)
+
class TestSimpleQueue(unittest.TestCase):
@classmethod