当前位置: 首页>>代码示例>>Python>>正文


Python signal.SIGQUIT属性代码示例

本文整理汇总了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) 
开发者ID:jpush,项目名称:jbox,代码行数:26,代码来源:arbiter.py

示例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 
开发者ID:galkan,项目名称:crowbar,代码行数:26,代码来源:main.py

示例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') 
开发者ID:aws,项目名称:sagemaker-tensorflow-serving-container,代码行数:21,代码来源:serve.py

示例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),
            },
        ) 
开发者ID:komuw,项目名称:naz,代码行数:27,代码来源:sig.py

示例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]) 
开发者ID:gkrizek,项目名称:bash-lambda-layer,代码行数:18,代码来源:compat.py

示例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) 
开发者ID:ActiveState,项目名称:code,代码行数:19,代码来源:recipe-579074.py

示例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() 
开发者ID:PolymorhicCode,项目名称:levye,代码行数:21,代码来源:main.py

示例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) 
开发者ID:TouwaStar,项目名称:Galaxy_Plugin_Bethesda,代码行数:27,代码来源:worker.py

示例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) 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:18,代码来源:base.py

示例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) 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:21,代码来源:arbiter.py

示例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() 
开发者ID:Matir,项目名称:pwnableweb,代码行数:25,代码来源:client.py

示例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) 
开发者ID:aws,项目名称:sagemaker-containers,代码行数:18,代码来源:_server.py

示例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.") 
开发者ID:econchick,项目名称:mayhem,代码行数:18,代码来源:mayhem_4.py

示例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.") 
开发者ID:econchick,项目名称:mayhem,代码行数:18,代码来源:mayhem_3.py

示例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.") 
开发者ID:econchick,项目名称:mayhem,代码行数:20,代码来源:mayhem_8.py


注:本文中的signal.SIGQUIT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。