2
2
# Distributed under the terms of the GNU General Public License v2
3
3
4
4
import fcntl
5
- import multiprocessing
5
+ import multiprocessing as _multiprocessing
6
6
import warnings
7
7
import signal
8
8
import sys
17
17
18
18
_registered_run_exitfuncs = None
19
19
20
+ if _multiprocessing .get_start_method () == "forkserver" :
21
+ multiprocessing = _multiprocessing .get_context ("spawn" )
22
+ else :
23
+ multiprocessing = _multiprocessing
24
+
20
25
21
26
class ForkProcess (SpawnProcess ):
22
27
# NOTE: This class overrides the meaning of the SpawnProcess 'args'
@@ -33,7 +38,7 @@ class ForkProcess(SpawnProcess):
33
38
_file_names = ("connection" , "slave_fd" )
34
39
_files_dict = slot_dict_class (_file_names , prefix = "" )
35
40
36
- _HAVE_SEND_HANDLE = getattr (multiprocessing .reduction , "HAVE_SEND_HANDLE" , False )
41
+ _HAVE_SEND_HANDLE = getattr (_multiprocessing .reduction , "HAVE_SEND_HANDLE" , False )
37
42
38
43
def _start (self ):
39
44
if multiprocessing .get_start_method () == "fork" :
@@ -157,7 +162,7 @@ def _send_fd_pipes(self):
157
162
(self ._fd_pipes , fd_list ),
158
163
)
159
164
for fd in fd_list :
160
- multiprocessing .reduction .send_handle (
165
+ _multiprocessing .reduction .send_handle (
161
166
self ._files .connection ,
162
167
fd ,
163
168
self .pid ,
@@ -297,7 +302,7 @@ def _bootstrap(child_connection, have_send_handle, fd_pipes, target, args, kwarg
297
302
fd_pipes , fd_list = child_connection .recv ()
298
303
fd_pipes_map = {}
299
304
for fd in fd_list :
300
- fd_pipes_map [fd ] = multiprocessing .reduction .recv_handle (
305
+ fd_pipes_map [fd ] = _multiprocessing .reduction .recv_handle (
301
306
child_connection
302
307
)
303
308
child_connection .close ()
0 commit comments