]> granicus.if.org Git - python/commitdiff
bpo-31510: Fix multiprocessing test_many_processes() on macOS (#3857)
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 2 Oct 2017 15:27:34 +0000 (08:27 -0700)
committerGitHub <noreply@github.com>
Mon, 2 Oct 2017 15:27:34 +0000 (08:27 -0700)
On macOS, a process can exit with -SIGKILL if it is killed "early"
with SIGTERM.

Lib/test/_test_multiprocessing.py

index fda20f1f408f9042a74eab90e43421ae9ec0b2bc..8e004e21a4fd5ad7841bfc2fe2580cfe70e3c4e3 100644 (file)
@@ -501,8 +501,13 @@ class _TestProcess(BaseTestCase):
         for p in procs:
             join_process(p)
         if os.name != 'nt':
+            exitcodes = [-signal.SIGTERM]
+            if sys.platform == 'darwin':
+                # bpo-31510: On macOS, killing a freshly started process with
+                # SIGTERM sometimes kills the process with SIGKILL.
+                exitcodes.append(-signal.SIGKILL)
             for p in procs:
-                self.assertEqual(p.exitcode, -signal.SIGTERM)
+                self.assertIn(p.exitcode, exitcodes)
 
     def test_lose_target_ref(self):
         c = DummyCallable()