def handle_worker_expiration(self, expiration): worker_id, exitcode = expiration try: task = self.find_expired_task(worker_id) except LookupError: return else: error = ProcessExpired('Abnormal termination', code=exitcode) self.task_manager.task_done(task.id, error)
def _get_result(future, pipe, timeout): """Waits for result and handles communication errors.""" counter = count(step=SLEEP_UNIT) try: while not pipe.poll(SLEEP_UNIT): if timeout is not None and next(counter) >= timeout: return TimeoutError('Task Timeout', timeout) elif future.cancelled(): return CancelledError() return pipe.recv() except (EOFError, OSError): return ProcessExpired('Abnormal termination') except Exception as error: return error