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

Method set_exit_callback

tornado/process.py:254–274  ·  view source on GitHub ↗

Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libraries trying to handle the same signal. If you are u

(self, callback: Callable[[int], None])

Source from the content-addressed store, hash-verified

252 self.returncode = None # type: Optional[int]
253
254 def set_exit_callback(self, callback: Callable[[int], None]) -> None:
255 """Runs ``callback`` when this process exits.
256
257 The callback takes one argument, the return code of the process.
258
259 This method uses a ``SIGCHLD`` handler, which is a global setting
260 and may conflict if you have other libraries trying to handle the
261 same signal. If you are using more than one ``IOLoop`` it may
262 be necessary to call `Subprocess.initialize` first to designate
263 one ``IOLoop`` to run the signal handlers.
264
265 In many cases a close callback on the stdout or stderr streams
266 can be used as an alternative to an exit callback if the
267 signal handler is causing a problem.
268
269 Availability: Unix
270 """
271 self._exit_callback = callback
272 Subprocess.initialize()
273 Subprocess._waiting[self.pid] = self
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.

Callers 3

wait_for_exitMethod · 0.95
test_sigchildMethod · 0.95
test_sigchild_signalMethod · 0.95

Calls 2

_try_cleanup_processMethod · 0.80
initializeMethod · 0.45

Tested by 2

test_sigchildMethod · 0.76
test_sigchild_signalMethod · 0.76