MCPcopy
hub / github.com/tornadoweb/tornado / wait_for_exit

Method wait_for_exit

tornado/process.py:276–306  ·  view source on GitHub ↗

Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `subprocess.Popen.wait`). By default, raises `subpro

(self, raise_error: bool = True)

Source from the content-addressed store, hash-verified

274 Subprocess._try_cleanup_process(self.pid)
275
276 def wait_for_exit(self, raise_error: bool = True) -> "Future[int]":
277 """Returns a `.Future` which resolves when the process exits.
278
279 Usage::
280
281 ret = yield proc.wait_for_exit()
282
283 This is a coroutine-friendly alternative to `set_exit_callback`
284 (and a replacement for the blocking `subprocess.Popen.wait`).
285
286 By default, raises `subprocess.CalledProcessError` if the process
287 has a non-zero exit status. Use ``wait_for_exit(raise_error=False)``
288 to suppress this behavior and return the exit status without raising.
289
290 .. versionadded:: 4.2
291
292 Availability: Unix
293 """
294 future = Future() # type: Future[int]
295
296 def callback(ret: int) -> None:
297 if ret != 0 and raise_error:
298 # Unfortunately we don't have the original args any more.
299 future_set_exception_unless_cancelled(
300 future, CalledProcessError(ret, "unknown")
301 )
302 else:
303 future_set_result_unless_cancelled(future, ret)
304
305 self.set_exit_callback(callback)
306 return future
307
308 @classmethod
309 def initialize(cls) -> None:

Calls 1

set_exit_callbackMethod · 0.95

Tested by 3

test_sigchild_futureMethod · 0.76