Skip to content

Commit db011de

Browse files
committed
Use spawn instead of forkserver
This avoids forserver 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 db011de

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

+8-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,10 @@
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
2024

2125
class ForkProcess(SpawnProcess):
2226
# NOTE: This class overrides the meaning of the SpawnProcess 'args'
@@ -33,7 +37,7 @@ class ForkProcess(SpawnProcess):
3337
_file_names = ("connection", "slave_fd")
3438
_files_dict = slot_dict_class(_file_names, prefix="")
3539

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

3842
def _start(self):
3943
if multiprocessing.get_start_method() == "fork":
@@ -157,7 +161,7 @@ def _send_fd_pipes(self):
157161
(self._fd_pipes, fd_list),
158162
)
159163
for fd in fd_list:
160-
multiprocessing.reduction.send_handle(
164+
_multiprocessing.reduction.send_handle(
161165
self._files.connection,
162166
fd,
163167
self.pid,
@@ -297,7 +301,7 @@ def _bootstrap(child_connection, have_send_handle, fd_pipes, target, args, kwarg
297301
fd_pipes, fd_list = child_connection.recv()
298302
fd_pipes_map = {}
299303
for fd in fd_list:
300-
fd_pipes_map[fd] = multiprocessing.reduction.recv_handle(
304+
fd_pipes_map[fd] = _multiprocessing.reduction.recv_handle(
301305
child_connection
302306
)
303307
child_connection.close()

0 commit comments

Comments
 (0)