summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorPierre Glaser <pierreglaser@msn.com>2019-05-10 18:42:35 (GMT)
committerAntoine Pitrou <antoine@python.org>2019-05-10 18:42:35 (GMT)
commitd0d64ad1f5f1dc1630004091d7f8209546c1220a (patch)
tree930a44cdff935895a33f121da0f3fb63fcfdc100 /Lib/test/_test_multiprocessing.py
parent86ea58149c3e83f402cecd17e6a536865fb06ce1 (diff)
downloadcpython-d0d64ad1f5f1dc1630004091d7f8209546c1220a.zip
cpython-d0d64ad1f5f1dc1630004091d7f8209546c1220a.tar.gz
cpython-d0d64ad1f5f1dc1630004091d7f8209546c1220a.tar.bz2
bpo-36368: Ignore SIGINT in SharedMemoryManager servers. (GH-12483)
Fix a bug crashing SharedMemoryManager instances in interactive sessions after a Ctrl-C (KeyboardInterrupt) was sent.
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 836fde8..d97e423 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3734,6 +3734,30 @@ class _TestSharedMemory(BaseTestCase):
sms.close()
+ @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
+ def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
+ # bpo-36368: protect SharedMemoryManager server process from
+ # KeyboardInterrupt signals.
+ smm = multiprocessing.managers.SharedMemoryManager()
+ smm.start()
+
+ # make sure the manager works properly at the beginning
+ sl = smm.ShareableList(range(10))
+
+ # the manager's server should ignore KeyboardInterrupt signals, and
+ # maintain its connection with the current process, and success when
+ # asked to deliver memory segments.
+ os.kill(smm._process.pid, signal.SIGINT)
+
+ sl2 = smm.ShareableList(range(10))
+
+ # test that the custom signal handler registered in the Manager does
+ # not affect signal handling in the parent process.
+ with self.assertRaises(KeyboardInterrupt):
+ os.kill(os.getpid(), signal.SIGINT)
+
+ smm.shutdown()
+
def test_shared_memory_SharedMemoryManager_basics(self):
smm1 = multiprocessing.managers.SharedMemoryManager()
with self.assertRaises(ValueError):