本文整理汇总了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
示例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))
示例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
示例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))
示例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
示例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