python类SIGQUIT的实例源码

server.py 文件源码 项目:py-abci 作者: davebryson 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def run(self):
        """Option to calling manually calling start()/stop(). This will start
        the server and watch for signals to stop the server"""
        self.server.start()
        log.info(" ABCIServer started on port: {}".format(self.port))
        # wait for interrupt
        evt = Event()
        gevent.signal(signal.SIGQUIT, evt.set)
        gevent.signal(signal.SIGTERM, evt.set)
        gevent.signal(signal.SIGINT, evt.set)
        evt.wait()
        log.info("Shutting down server")
        self.server.stop()

    # TM will spawn off 3 connections: mempool, consensus, query
    # If an error happens in 1 it still leaves the others open which
    # means you don't have all the connections available to TM
test_gevent.py 文件源码 项目:core-python 作者: yidao620c 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_greenlet(self):
        """??????Greenlet????"""
        class MyGreenlet(gevent.Greenlet):
            def __init__(self, message, n):
                super(MyGreenlet, self).__init__()
                self.message = message
                self.n = n

            def _run(self):
                print(self.message)
                gevent.sleep(self.n)

        g1 = MyGreenlet("Hi there111!", 1)
        g1.start()
        g2 = MyGreenlet("Hi there222!", 2)
        g2.start()
        gevent.joinall([g1, g2])

    # def test_shutdown(self):
    #     def run_forever():
    #         _log.info('run_forever start..')
    #         gevent.sleep(1000)
    #     gevent.signal(signal.SIGQUIT, gevent.kill)
    #     thread = gevent.spawn(run_forever)
    #     thread.join()
mx.py 文件源码 项目:mx 作者: graalvm 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _send_sigquit():
    for p, args in _currentSubprocesses:

        def _isJava():
            if args:
                name = args[0].split(os.sep)[-1]
                return name == "java"
            return False

        if p is not None and _isJava():
            if get_os() == 'windows':
                log("mx: implement me! want to send SIGQUIT to my child process")
            else:
                # only send SIGQUIT to the child not the process group
                logv('sending SIGQUIT to ' + str(p.pid))
                os.kill(p.pid, signal.SIGQUIT)
            time.sleep(0.1)
arbiter.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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)
base.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
run.py 文件源码 项目:uvicorn 作者: encode 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def run(self, app, host, port):
        asyncio.get_event_loop().close()
        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

        loop = asyncio.get_event_loop()

        loop.add_signal_handler(signal.SIGQUIT, self.handle_exit, signal.SIGQUIT, None)
        loop.add_signal_handler(signal.SIGTERM, self.handle_exit, signal.SIGTERM, None)
        loop.add_signal_handler(signal.SIGINT, self.handle_exit, signal.SIGINT, None)
        loop.add_signal_handler(signal.SIGABRT, self.handle_exit, signal.SIGABRT, None)

        loop.create_task(self.create_server(loop, app, host, port))
        loop.create_task(self.tick(loop))

        logger.warning('Starting worker [{}] serving at: {}:{}'.format(os.getpid(), host, port))

        loop.run_forever()
tarsnap.py 文件源码 项目:snappy 作者: ricci 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def runTarsnap(args, timeout = None):
    command = [config.tarsnap_bin] + config.tarsnap_extra_args + args
    proc = subprocess.Popen(command,
                stdout = subprocess.PIPE, stderr = subprocess.PIPE,
                stdin = subprocess.DEVNULL, universal_newlines = True)
    result = CheapoCompletedProcess()
    try:
        result.stdout, result.stderr = proc.communicate(timeout = timeout)
        result.returncode = proc.wait()
        if result.returncode:
            sys.exit("Error running tarsnap:\nCommand: {}\nSTDOUT:\n{}\nSTDERR:\n{}\n".format(" ".join(command),result.stdout,result.stderr))
        return result
    except subprocess.TimeoutExpired:
        print("Tarsnap timed out, sending SIGQUIT...")
        proc.send_signal(signal.SIGQUIT)
        result.stdout, result.stderr = proc.communicate()
        result.returncode = proc.wait()
        print("Tarsnap finished")
        if result.returncode:
            sys.exit("Error running tarsnap:\nCommand: {}\nSTDOUT:\n{}\nSTDERR:\n{}\n".format(" ".join(command),result.stdout,result.stderr))
        return result
arbiter.py 文件源码 项目:chihu 作者: yelongyu 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
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)
        """
        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)
base.py 文件源码 项目:chihu 作者: yelongyu 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)

        if hasattr(signal, 'set_wakeup_fd'):
            signal.set_wakeup_fd(self.PIPE[1])
arbiter.py 文件源码 项目:ShelbySearch 作者: Agentscreech 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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)
        """

        unlink = self.reexec_pid == self.master_pid == 0 and not self.systemd
        sock.close_sockets(self.LISTENERS, unlink)

        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)
arbiter.py 文件源码 项目:Price-Comparator 作者: Thejas-1 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
base.py 文件源码 项目:Price-Comparator 作者: Thejas-1 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
base_crawler.py 文件源码 项目:onedrop 作者: seraphln 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def kill_worker(self, pid, sig=signal.SIGQUIT):
        """
            ???????????

            @param pid: ??kill?????
            @type pid: Int

            @param sig: kill?????
            @type sig: Signal
        """
        try:
            os.kill(pid, sig)
        except OSError as e:
            if e.errno == errno.ESRCH:
                try:
                    worker = self.WORKERS.pop(pid)
                    #TODO: clean worker
                except (KeyError, OSError):
                    return
                else:
                    raise e
arbiter.py 文件源码 项目:tabmaster 作者: NicolasMinghetti 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
main.py 文件源码 项目:squid_dedup 作者: frispete 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self):
        # process command line options and load config files
        self._config = Config()
        self._threads = []
        self._exiting = False
        self._reload = False

        # signal handling
        for sig, action in (
            (signal.SIGINT, self.shutdown),
            (signal.SIGQUIT, self.shutdown),
            (signal.SIGTERM, self.shutdown),
            (signal.SIGHUP, lambda s, f: setattr(self, '_reload', True)),
            (signal.SIGPIPE, signal.SIG_IGN),
        ):
            try:
                signal.signal(sig, action)
            except AttributeError:
                pass

        log.trace(self._config)
squid_dedup.py 文件源码 项目:squid_dedup 作者: frispete 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        # process command line options and load config files
        self._config = Config()
        self._threads = []
        self._exiting = False
        self._reload = False

        # signal handling
        for sig, action in (
            (signal.SIGINT, self.shutdown),
            (signal.SIGQUIT, self.shutdown),
            (signal.SIGTERM, self.shutdown),
            (signal.SIGHUP, lambda s, f: setattr(self, '_reload', True)),
            (signal.SIGPIPE, signal.SIG_IGN),
        ):
            try:
                signal.signal(sig, action)
            except AttributeError:
                pass

        log.trace(self._config)
internal.py 文件源码 项目:of 作者: OptimalBPM 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def signal_handler_unix(_signal, _frame):
    """
    Manage system signals
    :param _signal: The Posix signal See: http://pubs.opengroup.org/onlinepubs/009695399/
    :param _frame: Unused, interrupted stack frame.
    """
    _reason = None
    if _signal == signal.SIGHUP:
        _reason = 'Got SIGTERM, restarting..'
        stop_handler(_reason, _restart=True)
    else:
        if _signal == signal.SIGQUIT:
            _reason = 'Ctrl+D pressed, shutting down..'
        elif _signal == signal.SIGINT:
            _reason = 'Ctrl+C pressed, shutting down..'
        elif _signal == signal.SIGTERM:
            _reason = 'Got SIGTERM, shutting down..'

        stop_handler(_reason)
internal.py 文件源码 项目:of 作者: OptimalBPM 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def register_signals(_stop_handler):
    """
    Register a callback to gracefully handle the system being externally shut down (terminated)
    :param _stop_handler: A callback that helps the system shut down gracefully.
    """

    if _stop_handler:
        global stop_handler
        stop_handler = _stop_handler
    else:
        raise Exception("No stop handler, probably an internal error, needed for graceful shut down.")
    if os.name == "nt":
        try:
            import win32api
        except ImportError:
            version = ".".join(map(str, sys.version_info[:2]))
            raise Exception("pywin32 not installed for Python " + version)
        else:
            win32api.SetConsoleCtrlHandler(signal_handler_windows, True)
            write_to_log("Registered win32 ctrl handler", _category=EC_SERVICE, _severity=SEV_INFO)
    else:
        signal.signal(signal.SIGINT, signal_handler_unix)
        signal.signal(signal.SIGTERM, signal_handler_unix)
        signal.signal(signal.SIGQUIT, signal_handler_unix)
        signal.signal(signal.SIGHUP, signal_handler_unix)
worker.py 文件源码 项目:sanic 作者: channelcat 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init_signals(self):
        # 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)
AIWIBoardContext.py 文件源码 项目:RPiNWR 作者: ke4roh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __enter__(self):
        # Make sure to cleanup GPIO afterward
        if not self.__signals_trapped:
            self.__signals_trapped = True
            for sig in [signal.SIGQUIT, signal.SIGTERM, signal.SIGTSTP]:
                if hasattr(signal.getsignal(sig), '__call__'):
                    deleg = signal.getsignal(sig)

                    def delegate(signum, stack):
                        self.__exit__(None, None, None)
                        deleg(signum, stack)

                    signal.signal(sig, delegate)
                else:
                    def delegate(signum, stack):
                        self.__exit__(None, None, None)

                    signal.signal(sig, delegate)
        return self
arbiter.py 文件源码 项目:infiblog 作者: RajuKoushik 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
arbiter.py 文件源码 项目:metrics 作者: Jeremy-Friedman 项目源码 文件源码 阅读 48 收藏 0 点赞 0 评论 0
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)
arbiter.py 文件源码 项目:metrics 作者: Jeremy-Friedman 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
arbiter.py 文件源码 项目:logo-gen 作者: jellene4eva 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
base.py 文件源码 项目:logo-gen 作者: jellene4eva 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
arbiter.py 文件源码 项目:liberator 作者: libscie 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
arbiter.py 文件源码 项目:compatify 作者: hatooku 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
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)
base.py 文件源码 项目:compatify 作者: hatooku 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
arbiter.py 文件源码 项目:djanoDoc 作者: JustinChavez 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
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)
arbiter.py 文件源码 项目:Data-visualization 作者: insta-code1 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号