我们从Python开源项目中,提取了以下35个代码示例,用于说明如何使用signal.SIG。
def kill_worker(self, pid, sig): """\ Kill a worker :attr pid: int, worker pid :attr sig: `signal.SIG*` value """ try: os.kill(pid, sig) except OSError as e: if e.errno == errno.ESRCH: try: worker = self.WORKERS.pop(pid) worker.tmp.close() self.cfg.worker_exit(self, worker) return except (KeyError, OSError): return raise
def kill_workers(self, sig): """\ Kill all workers with the signal `sig` :attr sig: `signal.SIG*` value """ worker_pids = list(self.WORKERS.keys()) for pid in worker_pids: self.kill_worker(pid, sig)
def _setup_sigs(): sigs = {} for signame, sigval in vars(signal).items(): # We want all signal.SIG* but not signal.SIG_* if (not signame.startswith('SIG')) or signame.startswith('SIG_'): continue sigs.setdefault(sigval, [str(sigval)]).append(signame) return { sigval: '/'.join(signames) for sigval, signames in sigs.items() }