Merge "Raise KeyboardInterrupt on SIGTERM - Workaround"

This commit is contained in:
Zuul 2018-05-14 15:35:47 +00:00 committed by Gerrit Code Review
commit c312669bde

View File

@ -43,6 +43,7 @@ class WSGIService(object):
self._periodics_worker = None
self._shutting_down = semaphore.Semaphore()
signal.signal(signal.SIGHUP, self._handle_sighup)
signal.signal(signal.SIGTERM, self._handle_sigterm)
def _init_middleware(self):
"""Initialize WSGI middleware.
@ -198,6 +199,12 @@ class WSGIService(object):
def _handle_sighup(self, *args):
eventlet.spawn(self._handle_sighup_bg, *args)
def _handle_sigterm(self, *args):
# This is a workaround to ensure that shutdown() is done when recieving
# SIGTERM. Raising KeyboardIntrerrupt which won't be caught by any
# 'except Exception' clauses.
raise KeyboardInterrupt
def periodic_clean_up(): # pragma: no cover
try: