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

Function spawn_main

Lib/multiprocessing/spawn.py:98–123  ·  view source on GitHub ↗

Run code specified by data received over pipe

(pipe_handle, parent_pid=None, tracker_fd=None)

Source from the content-addressed store, hash-verified

96
97
98def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
99 '''
100 Run code specified by data received over pipe
101 '''
102 assert is_forking(sys.argv), "Not forking"
103 if sys.platform == 'win32':
104 import msvcrt
105 import _winapi
106
107 if parent_pid is not None:
108 source_process = _winapi.OpenProcess(
109 _winapi.SYNCHRONIZE | _winapi.PROCESS_DUP_HANDLE,
110 False, parent_pid)
111 else:
112 source_process = None
113 new_handle = reduction.duplicate(pipe_handle,
114 source_process=source_process)
115 fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
116 parent_sentinel = source_process
117 else:
118 from . import resource_tracker
119 resource_tracker._resource_tracker._fd = tracker_fd
120 fd = pipe_handle
121 parent_sentinel = os.dup(pipe_handle)
122 exitcode = _main(fd, parent_sentinel)
123 sys.exit(exitcode)
124
125
126def _main(fd, parent_sentinel):

Callers 1

freeze_supportFunction · 0.85

Calls 5

is_forkingFunction · 0.85
duplicateMethod · 0.80
_mainFunction · 0.70
dupMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…