Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid the multiprocessing forkserver method in Python 3.14 #3442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 14 additions & 5 deletions tests/test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ def exit_callback(callback, *args):


class TestMultiprocessing:

# Python 3.14 changed the non-macOS POSIX default to forkserver
# but the code in this module does not work with it
# See https://github.com/python/cpython/issues/125714
if multiprocessing.get_start_method() == 'forkserver':
_mp_context = multiprocessing.get_context(method='fork')
else:
_mp_context = multiprocessing.get_context()

# Test connection sharing between forks.
# See issue #1085 for details.

Expand All @@ -41,7 +50,7 @@ def target(conn):
assert conn.read_response() == b"PONG"
conn.disconnect()

proc = multiprocessing.Process(target=target, args=(conn,))
proc = self._mp_context.Process(target=target, args=(conn,))
proc.start()
proc.join(3)
assert proc.exitcode == 0
Expand Down Expand Up @@ -71,7 +80,7 @@ def target(conn, ev):
conn.send_command("ping")

ev = multiprocessing.Event()
proc = multiprocessing.Process(target=target, args=(conn, ev))
proc = self._mp_context.Process(target=target, args=(conn, ev))
proc.start()

conn.disconnect()
Expand Down Expand Up @@ -105,7 +114,7 @@ def target(pool):
assert conn.send_command("ping") is None
assert conn.read_response() == b"PONG"

proc = multiprocessing.Process(target=target, args=(pool,))
proc = self._mp_context.Process(target=target, args=(pool,))
proc.start()
proc.join(3)
assert proc.exitcode == 0
Expand Down Expand Up @@ -143,7 +152,7 @@ def target(pool, disconnect_event):

ev = multiprocessing.Event()

proc = multiprocessing.Process(target=target, args=(pool, ev))
proc = self._mp_context.Process(target=target, args=(pool, ev))
proc.start()

pool.disconnect()
Expand All @@ -159,7 +168,7 @@ def target(client):
assert client.ping() is True
del client

proc = multiprocessing.Process(target=target, args=(r,))
proc = self._mp_context.Process(target=target, args=(r,))
proc.start()
proc.join(3)
assert proc.exitcode == 0
Expand Down