File tree Expand file tree Collapse file tree
test_multiprocessing_forkserver Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5050default_family = 'AF_INET'
5151families = ['AF_INET' ]
5252
53- if hasattr (socket , 'AF_UNIX' ):
53+ if hasattr (socket , 'AF_UNIX' ) and sys . platform != 'cygwin' :
5454 default_family = 'AF_UNIX'
5555 families += ['AF_UNIX' ]
5656
Original file line number Diff line number Diff line change @@ -326,8 +326,10 @@ def _check_available(self):
326326 _concrete_contexts = {
327327 'fork' : ForkContext (),
328328 'spawn' : SpawnContext (),
329- 'forkserver' : ForkServerContext (),
330329 }
330+ if reduction .HAVE_SEND_HANDLE :
331+ _concrete_contexts ['forkserver' ] = ForkServerContext ()
332+
331333 # bpo-33725: running arbitrary code after fork() is no longer reliable
332334 # on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
333335 # gh-84559: We changed everyones default to a thread safeish one in 3.14.
Original file line number Diff line number Diff line change @@ -6143,7 +6143,10 @@ def test_preload_resources(self):
61436143 @only_run_in_spawn_testsuite ("avoids redundant testing." )
61446144 def test_mixed_startmethod (self ):
61456145 # Fork-based locks cannot be used with spawned process
6146- for process_method in ["spawn" , "forkserver" ]:
6146+ test_methods = ["spawn" ]
6147+ if "forkserver" in multiprocessing .get_all_start_methods ():
6148+ test_methods .append ("forkserver" )
6149+ for process_method in test_methods :
61476150 queue = multiprocessing .get_context ("fork" ).Queue ()
61486151 process_ctx = multiprocessing .get_context (process_method )
61496152 p = process_ctx .Process (target = close_queue , args = (queue ,))
@@ -6152,7 +6155,7 @@ def test_mixed_startmethod(self):
61526155 p .start ()
61536156
61546157 # non-fork-based locks can be used with all other start methods
6155- for queue_method in [ "spawn" , "forkserver" ] :
6158+ for queue_method in test_methods :
61566159 for process_method in multiprocessing .get_all_start_methods ():
61576160 queue = multiprocessing .get_context (queue_method ).Queue ()
61586161 process_ctx = multiprocessing .get_context (process_method )
Original file line number Diff line number Diff line change @@ -4065,11 +4065,7 @@ def test_config_reject_simple_queue_handler_multiprocessing_context(self):
40654065 # and thus cannot be used as a queue-like object (gh-124653)
40664066
40674067 import multiprocessing
4068-
4069- if support .MS_WINDOWS :
4070- start_methods = ['spawn' ]
4071- else :
4072- start_methods = ['spawn' , 'fork' , 'forkserver' ]
4068+ start_methods = multiprocessing .get_all_start_methods ()
40734069
40744070 for start_method in start_methods :
40754071 with self .subTest (start_method = start_method ):
@@ -4085,10 +4081,8 @@ def test_config_reject_simple_queue_handler_multiprocessing_context(self):
40854081 " assertions in multiprocessing" )
40864082 def test_config_queue_handler_multiprocessing_context (self ):
40874083 # regression test for gh-121723
4088- if support .MS_WINDOWS :
4089- start_methods = ['spawn' ]
4090- else :
4091- start_methods = ['spawn' , 'fork' , 'forkserver' ]
4084+ import multiprocessing
4085+ start_methods = multiprocessing .get_all_start_methods ()
40924086 for start_method in start_methods :
40934087 with self .subTest (start_method = start_method ):
40944088 ctx = multiprocessing .get_context (start_method )
Original file line number Diff line number Diff line change 66if support .PGO :
77 raise unittest .SkipTest ("test is not helpful for PGO" )
88
9- if sys .platform == "win32" :
9+ if sys .platform in ( "win32" , "cygwin" ) :
1010 raise unittest .SkipTest ("forkserver is not available on Windows" )
1111
1212if not support .has_fork_support :
You can’t perform that action at this time.
0 commit comments