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


Python options.signame函数代码示例

本文整理汇总了Python中supervisor.options.signame函数的典型用法代码示例。如果您正苦于以下问题:Python signame函数的具体用法?Python signame怎么用?Python signame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了signame函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: signal

    def signal(self, sig):
        """Send a signal to the subprocess, without intending to kill it.

        Return None if the signal was sent, or an error message string
        if an error occurred or if the subprocess is not running.
        """
        options = self.config.options
        if not self.pid:
            msg = ("attempted to send %s sig %s but it wasn't running" %
                   (self.config.name, signame(sig)))
            options.logger.debug(msg)
            return msg

        options.logger.debug('sending %s (pid %s) sig %s'
                             % (self.config.name,
                                self.pid,
                                signame(sig))
                             )

        self._assertInState(ProcessStates.RUNNING,ProcessStates.STARTING,
                            ProcessStates.STOPPING)

        try:
            options.kill(self.pid, sig)
        except:
            tb = traceback.format_exc()
            msg = 'unknown problem sending sig %s (%s):%s' % (
                                self.config.name, self.pid, tb)
            options.logger.critical(msg)
            self.change_state(ProcessStates.UNKNOWN)
            self.pid = 0
            return msg

        return None
开发者ID:HonestManXin,项目名称:supervisor,代码行数:34,代码来源:process.py

示例2: handle_signal

 def handle_signal(self):
     sig = self.options.get_signal()
     if sig:
         if sig in (signal.SIGTERM, signal.SIGINT, signal.SIGQUIT):
             self.options.logger.warn(
                 'received %s indicating exit request' % signame(sig))
             self.options.mood = SupervisorStates.SHUTDOWN
         elif sig == signal.SIGHUP:
             if self.options.mood == SupervisorStates.SHUTDOWN:
                 self.options.logger.warn(
                     'ignored %s indicating restart request (shutdown in progress)' % signame(sig))
             else:
                 self.options.logger.warn(
                     'received %s indicating restart request' % signame(sig))
                 self.options.mood = SupervisorStates.RESTARTING
         elif sig == signal.SIGCHLD:
             self.options.logger.debug(
                 'received %s indicating a child quit' % signame(sig))
         elif sig == signal.SIGUSR2:
             self.options.logger.info(
                 'received %s indicating log reopen request' % signame(sig))
             self.options.reopenlogs()
             for group in self.process_groups.values():
                 group.reopenlogs()
         else:
             self.options.logger.blather(
                 'received %s indicating nothing' % signame(sig))
开发者ID:Supervisor,项目名称:supervisor,代码行数:27,代码来源:supervisord.py

示例3: kill

    def kill(self, sig):
        """Send a signal to the subprocess.  This may or may not kill it.

        Return None if the signal was sent, or an error message string
        if an error occurred or if the subprocess is not running.
        """
        now = time.time()
        options = self.config.options
        if not self.pid:
            msg = ("attempted to kill %s with sig %s but it wasn't running" %
                   (self.config.name, signame(sig)))
            options.logger.debug(msg)
            return msg

        killasgroup = self.config.killasgroup and sig == signal.SIGKILL

        as_group = ""
        if killasgroup:
            as_group = "process group "

        options.logger.debug('killing %s (pid %s) %swith signal %s'
                             % (self.config.name,
                                self.pid,
                                as_group,
                                signame(sig))
                             )

        # RUNNING/STARTING/STOPPING -> STOPPING
        self.killing = 1
        self.delay = now + self.config.stopwaitsecs
        # we will already be in the STOPPING state if we're doing a
        # SIGKILL as a result of overrunning stopwaitsecs
        self._assertInState(ProcessStates.RUNNING,ProcessStates.STARTING,
                            ProcessStates.STOPPING)
        self.change_state(ProcessStates.STOPPING)

        pid = self.pid
        if killasgroup:
            # send to the whole process group instead
            pid = -self.pid

        try:
            options.kill(pid, sig)
        except:
            io = StringIO.StringIO()
            traceback.print_exc(file=io)
            tb = io.getvalue()
            msg = 'unknown problem killing %s (%s):%s' % (self.config.name,
                                                          self.pid, tb)
            options.logger.critical(msg)
            self.change_state(ProcessStates.UNKNOWN)
            self.pid = 0
            self.killing = 0
            self.delay = 0
            return msg
            
        return None
开发者ID:yannk,项目名称:supervisor,代码行数:57,代码来源:process.py

示例4: handle_signal

 def handle_signal(self):
     sig = self.options.get_signal()
     if sig:
         if sig in (signal.SIGTERM, signal.SIGINT):
             self.options.logger.warn('received %s indicating exit request' % signame(sig))
             self.options.mood = SupervisorStates.SHUTDOWN
         elif sig == signal.SIGABRT:
             self.options.logger.warn('received %s indicating restart request' % signame(sig))
             self.options.mood = SupervisorStates.RESTARTING
         # elif sig == signal.SIGCHLD:
         #     self.options.logger.debug('received %s indicating a child quit' % signame(sig))
         # elif sig == signal.SIGUSR2:
         #     self.options.logger.info('received %s indicating log reopen request' % signame(sig))
         #     self.options.reopenlogs()
         #     for group in self.process_groups.values():
         #         group.reopenlogs()
         else:
             self.options.logger.blather('received %s indicating nothing' % signame(sig))
开发者ID:alexsilva,项目名称:supervisor,代码行数:18,代码来源:supervisord.py

示例5: kill

    def kill(self, sig):
        """Send a signal to the subprocess.  This may or may not kill it.

        Return None if the signal was sent, or an error message string
        if an error occurred or if the subprocess is not running.
        """
        now = time.time()
        options = self.config.options

        # Properly stop processes in BACKOFF state.
        if self.state == ProcessStates.BACKOFF:
            msg = ("Attempted to kill %s, which is in BACKOFF state." %
                   (self.config.name))
            options.logger.debug(msg)
            self.change_state(ProcessStates.STOPPED)
            return None

        if not self.pid:
            msg = ("attempted to kill %s with sig %s but it wasn't running" %
                   (self.config.name, signame(sig)))
            options.logger.debug(msg)
            return msg

        #If we're in the stopping state, then we've already sent the stop
        #signal and this is the kill signal
        if self.state == ProcessStates.STOPPING:
            killasgroup = self.config.killasgroup
        else:
            killasgroup = self.config.stopasgroup

        as_group = ""
        if killasgroup:
            as_group = "process group "

        options.logger.debug('killing %s (pid %s) %swith signal %s'
                             % (self.config.name,
                                self.pid,
                                as_group,
                                signame(sig))
                             )

        # RUNNING/STARTING/STOPPING -> STOPPING
        self.killing = True
        self.delay = now + self.config.stopwaitsecs
        # we will already be in the STOPPING state if we're doing a
        # SIGKILL as a result of overrunning stopwaitsecs
        self._assertInState(ProcessStates.RUNNING,ProcessStates.STARTING,
                            ProcessStates.STOPPING)
        self.change_state(ProcessStates.STOPPING)

        pid = self.pid
        if killasgroup:
            # send to the whole process group instead
            pid = -self.pid

        try:
            options.kill(pid, sig)
        except:
            tb = traceback.format_exc()
            msg = 'unknown problem killing %s (%s):%s' % (self.config.name,
                                                          self.pid, tb)
            options.logger.critical(msg)
            self.change_state(ProcessStates.UNKNOWN)
            self.pid = 0
            self.killing = False
            self.delay = 0
            return msg

        return None
开发者ID:HonestManXin,项目名称:supervisor,代码行数:69,代码来源:process.py

示例6: restart

 def restart(self, sig):
     """ Restart with signal """
     # DIRTY killing process, need to rewrite completely (according to kill method)
     options = self.config.options
     if not self.pid:
         msg = "attempted to kill %s with sig %s but it wasn't running" % (self.config.name, signame(sig))
         options.logger.debug(msg)
         return msg
     pid = self.pid
     options.kill(pid, sig)
     return None
开发者ID:fedosov,项目名称:supervisor,代码行数:11,代码来源:process.py


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