]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149879: Fix multiprocessing tests on Cygwin (#150031)
authorVictor Stinner <vstinner@python.org>
Mon, 18 May 2026 22:45:35 +0000 (00:45 +0200)
committerGitHub <noreply@github.com>
Mon, 18 May 2026 22:45:35 +0000 (00:45 +0200)
* Disable AF_UNIX connection family on Cygwin.
* forkserver start method is not available on Cygwin: update tests
  for that.
* test_logging calls multiprocessing.get_all_start_methods().

Lib/multiprocessing/connection.py
Lib/multiprocessing/context.py
Lib/test/_test_multiprocessing.py
Lib/test/test_logging.py
Lib/test/test_multiprocessing_forkserver/__init__.py

index e37ec07d722ca860c9a842f678fa1425a7565e57..be2fc3edf5dce660f7d44b50eb5fc49939660ad2 100644 (file)
@@ -50,7 +50,7 @@ _MAX_PIPE_ATTEMPTS = 100
 default_family = 'AF_INET'
 families = ['AF_INET']
 
-if hasattr(socket, 'AF_UNIX'):
+if hasattr(socket, 'AF_UNIX') and sys.platform != 'cygwin':
     default_family = 'AF_UNIX'
     families += ['AF_UNIX']
 
index e1d251456024c075b4240b0d160a11033946c080..45c393798deaca2449f6b27d6d21bd0918b49217 100644 (file)
@@ -326,8 +326,10 @@ if sys.platform != 'win32':
     _concrete_contexts = {
         'fork': ForkContext(),
         'spawn': SpawnContext(),
-        'forkserver': ForkServerContext(),
     }
+    if reduction.HAVE_SEND_HANDLE:
+        _concrete_contexts['forkserver'] = ForkServerContext()
+
     # bpo-33725: running arbitrary code after fork() is no longer reliable
     # on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
     # gh-84559: We changed everyones default to a thread safeish one in 3.14.
index 580d9f2b32544e48d6de057c14866fdf605d251d..f044358dcbd40f9bc4606a8436e279ba6a412db1 100644 (file)
@@ -6143,7 +6143,10 @@ class TestStartMethod(unittest.TestCase):
     @only_run_in_spawn_testsuite("avoids redundant testing.")
     def test_mixed_startmethod(self):
         # Fork-based locks cannot be used with spawned process
-        for process_method in ["spawn", "forkserver"]:
+        test_methods = ["spawn"]
+        if "forkserver" in multiprocessing.get_all_start_methods():
+            test_methods.append("forkserver")
+        for process_method in test_methods:
             queue = multiprocessing.get_context("fork").Queue()
             process_ctx = multiprocessing.get_context(process_method)
             p = process_ctx.Process(target=close_queue, args=(queue,))
@@ -6152,7 +6155,7 @@ class TestStartMethod(unittest.TestCase):
                 p.start()
 
         # non-fork-based locks can be used with all other start methods
-        for queue_method in ["spawn", "forkserver"]:
+        for queue_method in test_methods:
             for process_method in multiprocessing.get_all_start_methods():
                 queue = multiprocessing.get_context(queue_method).Queue()
                 process_ctx = multiprocessing.get_context(process_method)
index f2cbc2514fce531349fab1a9940c705a07479847..2ab9e0b336c9fb555bf8aa64a6f7f08d1c17188d 100644 (file)
@@ -4065,11 +4065,7 @@ class ConfigDictTest(BaseTest):
         # and thus cannot be used as a queue-like object (gh-124653)
 
         import multiprocessing
-
-        if support.MS_WINDOWS:
-            start_methods = ['spawn']
-        else:
-            start_methods = ['spawn', 'fork', 'forkserver']
+        start_methods = multiprocessing.get_all_start_methods()
 
         for start_method in start_methods:
             with self.subTest(start_method=start_method):
@@ -4085,10 +4081,8 @@ class ConfigDictTest(BaseTest):
                                            " assertions in multiprocessing")
     def test_config_queue_handler_multiprocessing_context(self):
         # regression test for gh-121723
-        if support.MS_WINDOWS:
-            start_methods = ['spawn']
-        else:
-            start_methods = ['spawn', 'fork', 'forkserver']
+        import multiprocessing
+        start_methods = multiprocessing.get_all_start_methods()
         for start_method in start_methods:
             with self.subTest(start_method=start_method):
                 ctx = multiprocessing.get_context(start_method)
index 7b1b884ab297b571fcd44a84b7b1aa9c10e26f74..c58375e2861c62e638147d2b3147d0052c8e3ba1 100644 (file)
@@ -6,7 +6,7 @@ from test import support
 if support.PGO:
     raise unittest.SkipTest("test is not helpful for PGO")
 
-if sys.platform == "win32":
+if sys.platform in ("win32", "cygwin"):
     raise unittest.SkipTest("forkserver is not available on Windows")
 
 if not support.has_fork_support: