MCPcopy Create free account
hub / github.com/apache/tvm / _start

Method _start

python/tvm/support/popen_pool.py:160–192  ·  view source on GitHub ↗

Start a new subprocess if nothing is available

(self)

Source from the content-addressed store, hash-verified

158 self._remaining_uses = None
159
160 def _start(self):
161 """Start a new subprocess if nothing is available"""
162 if self._proc is not None:
163 return
164
165 # connect subprocess with a pair of pipes
166 main_read, worker_write = os.pipe()
167 worker_read, main_write = os.pipe()
168
169 cmd = [sys.executable, "-m", "tvm.exec.popen_worker"]
170 if sys.platform == "win32":
171 # pylint: disable=import-outside-toplevel
172 import msvcrt
173
174 worker_read_handle = msvcrt.get_osfhandle(worker_read)
175 worker_write_handle = msvcrt.get_osfhandle(worker_write)
176 os.set_handle_inheritable(worker_read_handle, True)
177 os.set_handle_inheritable(worker_write_handle, True)
178 cmd += [str(worker_read_handle), str(worker_write_handle)]
179 self._proc = subprocess.Popen(
180 cmd, close_fds=False, stdout=self._stdout, stderr=self._stderr
181 )
182 else:
183 cmd += [str(worker_read), str(worker_write)]
184 self._proc = subprocess.Popen(
185 cmd, pass_fds=(worker_read, worker_write), stdout=self._stdout, stderr=self._stderr
186 )
187
188 # close worker side of the pipe
189 os.close(worker_read)
190 os.close(worker_write)
191 self._reader = os.fdopen(main_read, "rb")
192 self._writer = os.fdopen(main_write, "wb")
193
194 def join(self, timeout=None):
195 """Join the current process worker before it terminates.

Callers 1

sendMethod · 0.95

Calls 2

strFunction · 0.85
closeMethod · 0.65

Tested by

no test coverage detected