本文整理汇总了Python中signal.SIGQUIT属性的典型用法代码示例。如果您正苦于以下问题:Python signal.SIGQUIT属性的具体用法?Python signal.SIGQUIT怎么用?Python signal.SIGQUIT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类signal
的用法示例。
在下文中一共展示了signal.SIGQUIT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stop
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def stop(self, graceful=True):
"""\
Stop workers
:attr graceful: boolean, If True (the default) workers will be
killed gracefully (ie. trying to wait for the current connection)
"""
if self.reexec_pid == 0 and self.master_pid == 0:
for l in self.LISTENERS:
l.close()
self.LISTENERS = []
sig = signal.SIGTERM
if not graceful:
sig = signal.SIGQUIT
limit = time.time() + self.cfg.graceful_timeout
# instruct the workers to exit
self.kill_workers(sig)
# wait until the graceful timeout
while self.WORKERS and time.time() < limit:
time.sleep(0.1)
self.kill_workers(signal.SIGKILL)
示例2: vnclogin
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def vnclogin(self, ip, port, keyfile):
vnc_cmd = "%s -passwd %s %s:%s" % (self.vncviewer_path, keyfile, ip, port)
if self.args.verbose == 2:
self.logger.output_file("CMD: %s" % vnc_cmd)
proc = subprocess.Popen(shlex.split(vnc_cmd), shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
brute = "LOG-VNC: " + ip + ":" + str(port) + " - " + keyfile
self.logger.log_file(brute)
# For every line out
for line in proc.stdout:
# Is debug enabled
if self.args.debug:
self.logger.output_file(line.decode("utf-8").rstrip())
if re.search(self.vnc_success, str(line)):
os.kill(proc.pid, signal.SIGQUIT)
result = bcolors.OKGREEN + "VNC-SUCCESS: " + bcolors.ENDC + bcolors.OKBLUE + ip + ":" + str(
port) + " - " + keyfile + bcolors.ENDC
self.logger.output_file(result)
Main.is_success = 1
break
示例3: _stop
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def _stop(self, *args): # pylint: disable=W0613
self._state = 'stopping'
log.info('stopping services')
try:
os.kill(self._nginx.pid, signal.SIGQUIT)
except OSError:
pass
try:
if self._gunicorn:
os.kill(self._gunicorn.pid, signal.SIGTERM)
except OSError:
pass
try:
os.kill(self._tfs.pid, signal.SIGTERM)
except OSError:
pass
self._state = 'stopped'
log.info('stopped')
示例4: _signal_handling
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def _signal_handling(logger: logging.Logger, client: naz.Client) -> None:
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.get_event_loop()
try:
for _signal in [signal.SIGHUP, signal.SIGQUIT, signal.SIGTERM]:
loop.add_signal_handler(
_signal,
functools.partial(
asyncio.ensure_future,
_handle_termination_signal(logger=logger, _signal=_signal, client=client),
),
)
except ValueError as e:
logger.log(
logging.DEBUG,
{
"event": "naz.cli.signals",
"stage": "end",
"state": "this OS does not support the said signal",
"error": str(e),
},
)
示例5: ignore_user_entered_signals
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def ignore_user_entered_signals():
"""
Ignores user entered signals to avoid process getting killed.
"""
if is_windows:
signal_list = [signal.SIGINT]
else:
signal_list = [signal.SIGINT, signal.SIGQUIT, signal.SIGTSTP]
actual_signals = []
for user_signal in signal_list:
actual_signals.append(signal.signal(user_signal, signal.SIG_IGN))
try:
yield
finally:
for sig, user_signal in enumerate(signal_list):
signal.signal(user_signal, actual_signals[sig])
示例6: _install_signal_handlers
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def _install_signal_handlers(self):
"""Install signal handlers for the process.
"""
self._log.info('Installing signal handlers')
def handler(signum, _):
"""Signal handler.
"""
self._log.info('Got signal %s', signum)
self._stop_event.set()
for sig in (signal.SIGHUP, signal.SIGINT, signal.SIGTERM,
signal.SIGQUIT, signal.SIGABRT):
signal.signal(sig, handler)
示例7: openvpnlogin
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def openvpnlogin(self, host, username, password, brute_file, port):
brute_file_name = brute_file.name
brute_file.seek(0)
openvpn_cmd = "%s --config %s --auth-user-pass %s --remote %s %s"% (self.openvpn_path, self.args.config, brute_file_name, host, port)
proc = subprocess.Popen(shlex.split(openvpn_cmd), shell=False, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
brute = "LOG: OPENVPN: " + host + ":" + username + ":" + password + ":" + brute_file_name + "\n"
self.fd_log_file.write(brute)
for line in iter(proc.stdout.readline, ''):
if re.search(self.vpn_success, line):
now = datetime.datetime.now()
result = "SUCCESS," + now.strftime("%Y-%m-%d %H:%M:%S") + "," + "OPENVPN," + host + "," + username + "," + password + "\n"
print result[:-1]
self.fd_output_file.write(result)
os.kill(proc.pid, signal.SIGQUIT)
brute_file.close()
示例8: init_signals
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def init_signals(self) -> None:
# Set up signals through the event loop API.
self.loop.add_signal_handler(signal.SIGQUIT, self.handle_quit,
signal.SIGQUIT, None)
self.loop.add_signal_handler(signal.SIGTERM, self.handle_exit,
signal.SIGTERM, None)
self.loop.add_signal_handler(signal.SIGINT, self.handle_quit,
signal.SIGINT, None)
self.loop.add_signal_handler(signal.SIGWINCH, self.handle_winch,
signal.SIGWINCH, None)
self.loop.add_signal_handler(signal.SIGUSR1, self.handle_usr1,
signal.SIGUSR1, None)
self.loop.add_signal_handler(signal.SIGABRT, self.handle_abort,
signal.SIGABRT, None)
# Don't let SIGTERM and SIGUSR1 disturb active requests
# by interrupting system calls
signal.siginterrupt(signal.SIGTERM, False)
signal.siginterrupt(signal.SIGUSR1, False)
示例9: init_signals
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def init_signals(self):
# reset signaling
[signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS]
# init new signaling
signal.signal(signal.SIGQUIT, self.handle_quit)
signal.signal(signal.SIGTERM, self.handle_exit)
signal.signal(signal.SIGINT, self.handle_quit)
signal.signal(signal.SIGWINCH, self.handle_winch)
signal.signal(signal.SIGUSR1, self.handle_usr1)
signal.signal(signal.SIGABRT, self.handle_abort)
# Don't let SIGTERM and SIGUSR1 disturb active requests
# by interrupting system calls
if hasattr(signal, 'siginterrupt'): # python >= 2.6
signal.siginterrupt(signal.SIGTERM, False)
signal.siginterrupt(signal.SIGUSR1, False)
示例10: stop
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def stop(self, graceful=True):
"""\
Stop workers
:attr graceful: boolean, If True (the default) workers will be
killed gracefully (ie. trying to wait for the current connection)
"""
self.LISTENERS = []
sig = signal.SIGTERM
if not graceful:
sig = signal.SIGQUIT
limit = time.time() + self.cfg.graceful_timeout
# instruct the workers to exit
self.kill_workers(sig)
# wait until the graceful timeout
while self.WORKERS and time.time() < limit:
time.sleep(0.1)
self.kill_workers(signal.SIGKILL)
示例11: _start_internal
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def _start_internal(self):
self._started = True
# Signals
for sig in (signal.SIGINT, signal.SIGQUIT, signal.SIGTERM):
signal.signal(sig, self.stop)
# Setup the browser & xvfb
self.xvfb = xvfbwrapper.Xvfb(width=1024, height=768)
self.xvfb.start()
self.browser = webdriver.Chrome(executable_path=self._chromedriver_path)
self._run_event.set()
self._stop_event.clear()
self._thread = threading.Thread(target=self._wrap_run)
self._thread.start()
try:
while True:
time.sleep(self._interval)
self._run_event.set()
except KeyboardInterrupt:
print 'Saw CTRL-C, shutting down.'
self.stop()
示例12: _add_sigterm_handler
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def _add_sigterm_handler(nginx, gunicorn):
"""Placeholder docstring"""
def _terminate(signo, frame): # pylint: disable=unused-argument
if nginx:
try:
os.kill(nginx.pid, signal.SIGQUIT)
except OSError:
pass
try:
os.kill(gunicorn.pid, signal.SIGTERM)
except OSError:
pass
signal.signal(signal.SIGTERM, _terminate)
示例13: main
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def main():
executor = concurrent.futures.ThreadPoolExecutor()
loop = asyncio.get_event_loop()
signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT)
for s in signals:
loop.add_signal_handler(
s, lambda s=s: asyncio.create_task(shutdown(loop, executor, signal=s)))
q = queue.Queue()
try:
loop.create_task(publish(executor, q))
loop.create_task(consume(executor, q))
loop.run_forever()
finally:
loop.close()
logging.info("Successfully shutdown the Mayhem service.")
示例14: main
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def main():
executor = concurrent.futures.ThreadPoolExecutor()
loop = asyncio.get_event_loop()
signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT)
for s in signals:
loop.add_signal_handler(
s, lambda s=s: asyncio.create_task(shutdown(loop, signal=s)))
q = queue.Queue()
try:
loop.create_task(publish(executor, q))
loop.create_task(consume(executor, q))
loop.run_forever()
finally:
loop.close()
logging.info("Successfully shutdown the Mayhem service.")
示例15: main
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGQUIT [as 别名]
def main():
executor = concurrent.futures.ThreadPoolExecutor()
loop = asyncio.get_event_loop()
signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT)
for s in signals:
loop.add_signal_handler(
s, lambda s=s: asyncio.create_task(shutdown(loop, executor, signal=s)))
handle_exc_func = functools.partial(handle_exception, executor)
loop.set_exception_handler(handle_exc_func)
q = queue.Queue()
try:
loop.create_task(publish(executor, q))
loop.create_task(consume(executor, q))
loop.run_forever()
finally:
loop.close()
logging.info("Successfully shutdown the Mayhem service.")