本文整理汇总了Python中signal.SIG属性的典型用法代码示例。如果您正苦于以下问题:Python signal.SIG属性的具体用法?Python signal.SIG怎么用?Python signal.SIG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类signal
的用法示例。
在下文中一共展示了signal.SIG属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: kill_worker
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIG [as 别名]
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
示例2: kill_workers
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIG [as 别名]
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)
示例3: _setup_sigs
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIG [as 别名]
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()
}
示例4: __init__
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIG [as 别名]
def __init__(
self,
spinner=None,
text="",
color=None,
on_color=None,
attrs=None,
reversal=False,
side="left",
sigmap=None,
):
# Spinner
self._spinner = self._set_spinner(spinner)
self._frames = self._set_frames(self._spinner, reversal)
self._interval = self._set_interval(self._spinner)
self._cycle = self._set_cycle(self._frames)
# Color Specification
self._color = self._set_color(color) if color else color
self._on_color = self._set_on_color(on_color) if on_color else on_color
self._attrs = self._set_attrs(attrs) if attrs else set()
self._color_func = self._compose_color_func()
# Other
self._text = self._set_text(text)
self._side = self._set_side(side)
self._reversal = reversal
# Helper flags
self._stop_spin = None
self._hide_spin = None
self._spin_thread = None
self._last_frame = None
self._stdout_lock = threading.Lock()
# Signals
# In Python 2 signal.SIG* are of type int.
# In Python 3 signal.SIG* are enums.
#
# Signal = Union[enum.Enum, int]
# SigHandler = Union[enum.Enum, Callable]
self._sigmap = sigmap if sigmap else {} # Dict[Signal, SigHandler]
# Maps signals to their default handlers in order to reset
# custom handlers set by ``sigmap`` at the cleanup phase.
self._dfl_sigmap = {} # Dict[Signal, SigHandler]
#
# Dunders
#