def _get_last_worker_died(self): """Return the last died worker information or None""" for service_id in self._running_services: # We copy the list to clean the orignal one processes = list(self._running_services[service_id].items()) for process, worker_id in processes: if not process.is_alive(): if process.exitcode < 0: sig = _utils.signal_to_name(process.exitcode) LOG.info('Child %(pid)d killed by signal %(sig)s', dict(pid=process.pid, sig=sig)) else: LOG.info('Child %(pid)d exited with status %(code)d', dict(pid=process.pid, code=process.exitcode)) del self._running_services[service_id][process] return service_id, worker_id
def _get_last_pid_died(self): """Return the last died service or None""" try: # Don't block if no child processes have exited pid, status = os.waitpid(0, os.WNOHANG) if not pid: return None except OSError as exc: if exc.errno not in (errno.EINTR, errno.ECHILD): raise return None if os.WIFSIGNALED(status): sig = _utils.signal_to_name(os.WTERMSIG(status)) LOG.info('Child %(pid)d killed by signal %(sig)s', dict(pid=pid, sig=sig)) else: code = os.WEXITSTATUS(status) LOG.info('Child %(pid)d exited with status %(code)d', dict(pid=pid, code=code)) return pid