Skip to content

Commit 4f6c707

Browse files
committed
Use spawn instead of forkserver
This avoids forkserver errors of the form: OSError: AF_UNIX path too long Bug: https://bugs.gentoo.org/941956 Signed-off-by: Zac Medico <[email protected]>
1 parent c3d2596 commit 4f6c707

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Diff for: .github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,7 @@ jobs:
9696
export PYTEST_ADDOPTS="-vv -ra -l -o console_output_style=count -n $(nproc) --dist=worksteal"
9797
# Use pytest-rerunfailures to workaround pytest-xdist worker crashes with spawn start-method (bug 924416).
9898
[[ "${{ matrix.start-method }}" == "spawn" ]] && PYTEST_ADDOPTS+=" --reruns 5 --only-rerun 'worker .* crashed while running'"
99+
[[ "${{ matrix.start-method }}" == "fork" ]] &&
100+
[[ "${{ matrix.python-version }}" == "3.14-dev" ]] &&
101+
PYTEST_ADDOPTS+=" --reruns 5 --only-rerun 'node down: Not properly terminated'"
99102
meson test -C /tmp/build --verbose

Diff for: lib/portage/locks.py

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
import typing
2828
import warnings
2929

30+
if multiprocessing.get_start_method() == "forkserver":
31+
multiprocessing = multiprocessing.get_context("spawn")
32+
3033
import portage
3134
from portage import os, _encodings, _unicode_decode
3235
from portage.exception import (

Diff for: lib/portage/util/_async/ForkProcess.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Distributed under the terms of the GNU General Public License v2
33

44
import fcntl
5-
import multiprocessing
5+
import multiprocessing as _multiprocessing
66
import warnings
77
import signal
88
import sys
@@ -17,6 +17,11 @@
1717

1818
_registered_run_exitfuncs = None
1919

20+
if _multiprocessing.get_start_method() == "forkserver":
21+
multiprocessing = _multiprocessing.get_context("spawn")
22+
else:
23+
multiprocessing = _multiprocessing
24+
2025

2126
class ForkProcess(SpawnProcess):
2227
# NOTE: This class overrides the meaning of the SpawnProcess 'args'
@@ -33,7 +38,7 @@ class ForkProcess(SpawnProcess):
3338
_file_names = ("connection", "slave_fd")
3439
_files_dict = slot_dict_class(_file_names, prefix="")
3540

36-
_HAVE_SEND_HANDLE = getattr(multiprocessing.reduction, "HAVE_SEND_HANDLE", False)
41+
_HAVE_SEND_HANDLE = getattr(_multiprocessing.reduction, "HAVE_SEND_HANDLE", False)
3742

3843
def _start(self):
3944
if multiprocessing.get_start_method() == "fork":
@@ -157,7 +162,7 @@ def _send_fd_pipes(self):
157162
(self._fd_pipes, fd_list),
158163
)
159164
for fd in fd_list:
160-
multiprocessing.reduction.send_handle(
165+
_multiprocessing.reduction.send_handle(
161166
self._files.connection,
162167
fd,
163168
self.pid,
@@ -297,7 +302,7 @@ def _bootstrap(child_connection, have_send_handle, fd_pipes, target, args, kwarg
297302
fd_pipes, fd_list = child_connection.recv()
298303
fd_pipes_map = {}
299304
for fd in fd_list:
300-
fd_pipes_map[fd] = multiprocessing.reduction.recv_handle(
305+
fd_pipes_map[fd] = _multiprocessing.reduction.recv_handle(
301306
child_connection
302307
)
303308
child_connection.close()

0 commit comments

Comments
 (0)