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
20
24
21
25
class ForkProcess (SpawnProcess ):
22
26
# NOTE: This class overrides the meaning of the SpawnProcess 'args'
@@ -33,7 +37,7 @@ class ForkProcess(SpawnProcess):
33
37
_file_names = ("connection" , "slave_fd" )
34
38
_files_dict = slot_dict_class (_file_names , prefix = "" )
35
39
36
- _HAVE_SEND_HANDLE = getattr (multiprocessing .reduction , "HAVE_SEND_HANDLE" , False )
40
+ _HAVE_SEND_HANDLE = getattr (_multiprocessing .reduction , "HAVE_SEND_HANDLE" , False )
37
41
38
42
def _start (self ):
39
43
if multiprocessing .get_start_method () == "fork" :
@@ -157,7 +161,7 @@ def _send_fd_pipes(self):
157
161
(self ._fd_pipes , fd_list ),
158
162
)
159
163
for fd in fd_list :
160
- multiprocessing .reduction .send_handle (
164
+ _multiprocessing .reduction .send_handle (
161
165
self ._files .connection ,
162
166
fd ,
163
167
self .pid ,
@@ -297,7 +301,7 @@ def _bootstrap(child_connection, have_send_handle, fd_pipes, target, args, kwarg
297
301
fd_pipes , fd_list = child_connection .recv ()
298
302
fd_pipes_map = {}
299
303
for fd in fd_list :
300
- fd_pipes_map [fd ] = multiprocessing .reduction .recv_handle (
304
+ fd_pipes_map [fd ] = _multiprocessing .reduction .recv_handle (
301
305
child_connection
302
306
)
303
307
child_connection .close ()
0 commit comments