@@ -18,6 +18,15 @@ def exit_callback(callback, *args):
1818
1919
2020class TestMultiprocessing :
21+
22+ # Python 3.14 changed the non-macOS POSIX default to forkserver
23+ # but the code in this module does not work with it
24+ # See https://github.com/python/cpython/issues/125714
25+ if multiprocessing .get_start_method () == 'forkserver' :
26+ _mp_context = multiprocessing .get_context (method = 'fork' )
27+ else :
28+ _mp_context = multiprocessing .get_context ()
29+
2130 # Test connection sharing between forks.
2231 # See issue #1085 for details.
2332
@@ -41,7 +50,7 @@ def target(conn):
4150 assert conn .read_response () == b"PONG"
4251 conn .disconnect ()
4352
44- proc = multiprocessing .Process (target = target , args = (conn ,))
53+ proc = self . _mp_context .Process (target = target , args = (conn ,))
4554 proc .start ()
4655 proc .join (3 )
4756 assert proc .exitcode == 0
@@ -71,7 +80,7 @@ def target(conn, ev):
7180 conn .send_command ("ping" )
7281
7382 ev = multiprocessing .Event ()
74- proc = multiprocessing .Process (target = target , args = (conn , ev ))
83+ proc = self . _mp_context .Process (target = target , args = (conn , ev ))
7584 proc .start ()
7685
7786 conn .disconnect ()
@@ -105,7 +114,7 @@ def target(pool):
105114 assert conn .send_command ("ping" ) is None
106115 assert conn .read_response () == b"PONG"
107116
108- proc = multiprocessing .Process (target = target , args = (pool ,))
117+ proc = self . _mp_context .Process (target = target , args = (pool ,))
109118 proc .start ()
110119 proc .join (3 )
111120 assert proc .exitcode == 0
@@ -143,7 +152,7 @@ def target(pool, disconnect_event):
143152
144153 ev = multiprocessing .Event ()
145154
146- proc = multiprocessing .Process (target = target , args = (pool , ev ))
155+ proc = self . _mp_context .Process (target = target , args = (pool , ev ))
147156 proc .start ()
148157
149158 pool .disconnect ()
@@ -159,7 +168,7 @@ def target(client):
159168 assert client .ping () is True
160169 del client
161170
162- proc = multiprocessing .Process (target = target , args = (r ,))
171+ proc = self . _mp_context .Process (target = target , args = (r ,))
163172 proc .start ()
164173 proc .join (3 )
165174 assert proc .exitcode == 0
0 commit comments