MCPcopy Index your code
hub / github.com/python/cpython / _launch

Method _launch

Lib/multiprocessing/popen_spawn_posix.py:38–76  ·  view source on GitHub ↗
(self, process_obj)

Source from the content-addressed store, hash-verified

36 return fd
37
38 def _launch(self, process_obj):
39 from . import resource_tracker
40 tracker_fd = resource_tracker.getfd()
41 self._fds.append(tracker_fd)
42 prep_data = spawn.get_preparation_data(process_obj._name)
43 fp = io.BytesIO()
44 set_spawning_popen(self)
45 try:
46 reduction.dump(prep_data, fp)
47 reduction.dump(process_obj, fp)
48 finally:
49 set_spawning_popen(None)
50
51 parent_r = child_w = child_r = parent_w = None
52 try:
53 parent_r, child_w = os.pipe()
54 child_r, parent_w = os.pipe()
55 cmd = spawn.get_command_line(tracker_fd=tracker_fd,
56 pipe_handle=child_r)
57 self._fds.extend([child_r, child_w])
58 self.pid = util.spawnv_passfds(spawn.get_executable(),
59 cmd, self._fds)
60 os.close(child_r)
61 child_r = None
62 os.close(child_w)
63 child_w = None
64 self.sentinel = parent_r
65 with open(parent_w, 'wb', closefd=False) as f:
66 f.write(fp.getbuffer())
67 finally:
68 fds_to_close = []
69 for fd in (parent_r, parent_w):
70 if fd is not None:
71 fds_to_close.append(fd)
72 self.finalizer = util.Finalize(self, util.close_fds, fds_to_close)
73
74 for fd in (child_r, child_w):
75 if fd is not None:
76 os.close(fd)

Callers

nothing calls this directly

Calls 10

getbufferMethod · 0.95
set_spawning_popenFunction · 0.85
openFunction · 0.50
getfdMethod · 0.45
appendMethod · 0.45
dumpMethod · 0.45
pipeMethod · 0.45
extendMethod · 0.45
closeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected