def _close(self, abort, timeout): """ Close client. See EngineClient._close(). """ if abort: # it's safer to call poll() first for long time completed processes prc = self.popen.poll() # if prc is None, process is still running if prc is None: try: # try to kill it self.popen.kill() except OSError: pass prc = self.popen.wait() self.streams.clear() self.invalidate() if prc >= 0: # filter valid rc self.rc = prc self.worker._on_close(self.key, prc) elif timeout: assert abort, "abort flag not set on timeout" self.worker._on_timeout(self.key) elif not abort: # if process was signaled, return 128 + signum (bash-like) self.rc = 128 + -prc self.worker._on_close(self.key, self.rc) if self.worker.eh is not None: _eh_sigspec_invoke_compat(self.worker.eh.ev_close, 2, self.worker, timeout)
def _close(self, abort, timeout): """ Close client. See EngineClient._close(). """ if abort: # it's safer to call poll() first for long time completed processes prc = self.popen.poll() # if prc is None, process is still running if prc is None: try: # try to kill it self.popen.kill() except OSError: pass prc = self.popen.wait() self.streams.clear() self.invalidate() if prc >= 0: # filter valid rc self.rc = prc self.worker._on_close(self.key, prc) elif timeout: assert abort, "abort flag not set on timeout" self.worker._on_timeout(self.key) elif not abort: # if process was signaled, return 128 + signum (bash-like) self.rc = 128 + -prc self.worker._on_close(self.key, self.rc) if self.worker.eh is not None: _eh_sigspec_invoke_compat(self.worker.eh.ev_close, 2, self.worker, timeout)
def _check_ini(self): self.logger.debug("TreeWorker: _check_ini (%d, %d)", self._start_count, self._child_count) if self.eh and self._start_count >= self._child_count: # this part is called once self.eh.ev_start(self) # Blindly generate pickup events: this could maybe be improved, for # example, generated only when commands are sent to the gateways # or for direct targets, using MetaWorkerEventHandler. for node in self.nodes: _eh_sigspec_invoke_compat(self.eh.ev_pickup, 2, self, node)
def _check_fini(self): """ Must be called by each client when closing. If they are all closed, trigger the required events. """ self._close_count += 1 assert self._close_count <= len(self._clients) if self._close_count == len(self._clients) and self.eh is not None: if self._has_timeout and hasattr(self.eh, 'ev_timeout'): # Legacy ev_timeout event self.eh.ev_timeout(self) _eh_sigspec_invoke_compat(self.eh.ev_close, 2, self, self._has_timeout)
def _check_fini(self): """ Must be called by each client when closing. If they are all closed, trigger the required events. """ self._close_count += 1 assert self._close_count <= len(self._clients) if self._close_count == len(self._clients) and self.eh is not None: # also use hasattr check because ev_timeout was missing in 1.8.0 if self._has_timeout and hasattr(self.eh, 'ev_timeout'): # Legacy ev_timeout event self.eh.ev_timeout(self) _eh_sigspec_invoke_compat(self.eh.ev_close, 2, self, self._has_timeout)
def _check_fini(self, gateway=None): self.logger.debug("check_fini %s %s", self._close_count, self._target_count) if self._close_count >= self._target_count: handler = self.eh if handler: # also use hasattr check because ev_timeout was missing in 1.8.0 if self._has_timeout and hasattr(handler, 'ev_timeout'): handler.ev_timeout(self) _eh_sigspec_invoke_compat(handler.ev_close, 2, self, self._has_timeout) # check completion of targets per gateway if gateway: targets = self.gwtargets[str(gateway)] if not targets: # no more active targets for this gateway self.logger.debug("TreeWorker._check_fini %s call pchannel_" "release for gw %s", self, gateway) self.task._pchannel_release(gateway, self) del self.gwtargets[str(gateway)]