Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/multiprocessing/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
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']

Expand Down
7 changes: 4 additions & 3 deletions Lib/multiprocessing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,15 @@ def _check_available(self):
raise ValueError('forkserver start method not available')

_concrete_contexts = {
'fork': ForkContext(),
'spawn': SpawnContext(),
'forkserver': ForkServerContext(),
}
if sys.platform != 'cygwin':
_concrete_contexts['fork'] = ForkContext()
_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.
if reduction.HAVE_SEND_HANDLE and sys.platform != 'darwin':
if reduction.HAVE_SEND_HANDLE and sys.platform not in ('darwin', 'cygwin'):
_default_context = DefaultContext(_concrete_contexts['forkserver'])
else:
_default_context = DefaultContext(_concrete_contexts['spawn'])
Expand Down
7 changes: 5 additions & 2 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def _resource_unlink(name, rtype):
'HAVE_BROKEN_SEM_GETVALUE', False)

WIN32 = (sys.platform == "win32")
ALL_START_METHODS = multiprocessing.get_all_start_methods()

def wait_for_handle(handle, timeout):
if timeout is not None and timeout < 0.0:
Expand Down Expand Up @@ -239,6 +240,8 @@ class TestInternalDecorators(unittest.TestCase):
"""Logic within a test suite that could errantly skip tests? Test it!"""

@support.requires_fork()
# Cygwin has fork() but lacks start method 'fork'
@unittest.skipUnless('fork' in ALL_START_METHODS, 'need fork start method')
def test_only_run_in_spawn_testsuite(self):
if multiprocessing.get_start_method() != "spawn":
raise unittest.SkipTest("only run in test_multiprocessing_spawn.")
Expand Down Expand Up @@ -6104,7 +6107,7 @@ def test_set_get(self):
def test_get_all_start_methods(self):
methods = multiprocessing.get_all_start_methods()
self.assertIn('spawn', methods)
if sys.platform == 'win32':
if sys.platform in ('win32', 'cygwin'):
self.assertEqual(methods, ['spawn'])
elif sys.platform == 'darwin':
self.assertEqual(methods[0], 'spawn') # The default is first.
Expand Down Expand Up @@ -6138,7 +6141,7 @@ def test_preload_resources(self):
self.fail("failed spawning forkserver or grandchild")

@warnings_helper.ignore_fork_in_thread_deprecation_warnings()
@unittest.skipIf(sys.platform == "win32",
@unittest.skipIf(sys.platform in ("win32", "cygwin"),
"Only Spawn on windows so no risk of mixing")
@only_run_in_spawn_testsuite("avoids redundant testing.")
def test_mixed_startmethod(self):
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_concurrent_futures/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def _assert_logged(self, msg):
create_executor_tests(globals(), FailingInitializerMixin)


@unittest.skipIf(sys.platform == "win32", "Resource Tracker doesn't run on Windows")
@unittest.skipIf(sys.platform in ("win32", "cygwin"),
"Resource Tracker doesn't run on Windows")
class FailingInitializerResourcesTest(unittest.TestCase):
"""
Source: https://github.com/python/cpython/issues/104090
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_concurrent_futures/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def get_context(self):
_check_system_limits()
except NotImplementedError:
self.skipTest("ProcessPoolExecutor unavailable on this system")
if sys.platform == "win32":
self.skipTest("require unix system")
if sys.platform in ("win32", "cygwin"):
self.skipTest("require Unix system")
if support.check_sanitizer(thread=True):
self.skipTest("TSAN doesn't support threads after fork")
return super().get_context()
Expand Down Expand Up @@ -135,8 +135,8 @@ def get_context(self):
_check_system_limits()
except NotImplementedError:
self.skipTest("ProcessPoolExecutor unavailable on this system")
if sys.platform == "win32":
self.skipTest("require unix system")
if sys.platform in ("win32", "cygwin"):
self.skipTest("require Unix system")
if support.check_sanitizer(thread=True):
self.skipTest("TSAN doesn't support threads after fork")
return super().get_context()
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4066,7 +4066,7 @@ def test_config_reject_simple_queue_handler_multiprocessing_context(self):

import multiprocessing

if support.MS_WINDOWS:
if support.MS_WINDOWS or sys.platform == 'cygwin':
start_methods = ['spawn']
else:
start_methods = ['spawn', 'fork', 'forkserver']
Expand All @@ -4085,7 +4085,7 @@ def test_config_reject_simple_queue_handler_multiprocessing_context(self):
" assertions in multiprocessing")
def test_config_queue_handler_multiprocessing_context(self):
# regression test for gh-121723
if support.MS_WINDOWS:
if support.MS_WINDOWS or sys.platform == 'cygwin':
start_methods = ['spawn']
else:
start_methods = ['spawn', 'fork', 'forkserver']
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_multiprocessing_fork/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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("fork is not available on Windows")

if sys.platform == 'darwin':
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_multiprocessing_forkserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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:
Expand Down
Loading