我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用multiprocessing.forking()。
def _on_sigchld(self, watcher): """Callback of libev child watcher. Called when libev event loop catches corresponding SIGCHLD signal. """ watcher.stop() # Status evaluation copied from `multiprocessing.forking` in Py2.7. if os.WIFSIGNALED(watcher.rstatus): self._popen.returncode = -os.WTERMSIG(watcher.rstatus) else: assert os.WIFEXITED(watcher.rstatus) self._popen.returncode = os.WEXITSTATUS(watcher.rstatus) self._returnevent.set() log.debug("SIGCHLD watcher callback for %s invoked. Exitcode " "stored: %s", self.pid, self._popen.returncode)
def _make_nonblocking(self): if hasattr(gevent.os, 'make_nonblocking'): # On POSIX-compliant systems, the file descriptor flags are # inherited after forking, i.e. it is sufficient to make fd # nonblocking only once. gevent.os.make_nonblocking(self._fd)