move request_(force_)stop out of _install_signal_handlers

main
Samuel Colvin 9 years ago
parent ca235aee19
commit e750134e8a

@ -323,7 +323,10 @@ class Worker(object):
gracefully.
"""
def request_force_stop(signum, frame):
signal.signal(signal.SIGINT, self.request_stop)
signal.signal(signal.SIGTERM, self.request_stop)
def request_force_stop(self, signum, frame):
"""Terminates the application (cold shutdown).
"""
self.log.warning('Cold shut down')
@ -341,14 +344,14 @@ class Worker(object):
raise
raise SystemExit()
def request_stop(signum, frame):
def request_stop(self, signum, frame):
"""Stops the current worker loop but waits for child processes to
end gracefully (warm shutdown).
"""
self.log.debug('Got signal {0}'.format(signal_name(signum)))
signal.signal(signal.SIGINT, request_force_stop)
signal.signal(signal.SIGTERM, request_force_stop)
signal.signal(signal.SIGINT, self.request_force_stop)
signal.signal(signal.SIGTERM, self.request_force_stop)
msg = 'Warm shut down requested'
self.log.warning(msg)
@ -362,9 +365,6 @@ class Worker(object):
else:
raise StopRequested()
signal.signal(signal.SIGINT, request_stop)
signal.signal(signal.SIGTERM, request_stop)
def check_for_suspension(self, burst):
"""Check to see if workers have been suspended by `rq suspend`"""

Loading…
Cancel
Save