Commit 2b042f3e authored by Jérome Perrin's avatar Jérome Perrin

WIP clean shutdown

parent 8abbbd83
......@@ -92,7 +92,7 @@ class TimerServer(threading.Thread):
interval = self.interval
logger.info('Service ready.')
request_class = TimerRequest
while 1:
time.sleep(interval)
# send message to zope
......@@ -100,7 +100,9 @@ class TimerServer(threading.Thread):
out = StringIO()
err = StringIO()
response = TimerResponse(out, err)
handle(module, TimerRequest(response, interval), response)
if server.task_dispatcher.stop_count:
request_class = ShutdownTimerRequest
handle(module, request_class(response, interval), response)
except Exception:
logger.warn("Ignoring exception in run loop", exc_info=True)
......@@ -186,3 +188,10 @@ class TimerRequest(HTTPRequest):
clone = HTTPRequest(None, environ, HTTPResponse(), clean=1)
clone['PARENTS'] = [self['PARENTS'][-1]]
return clone
class ShutdownTimerRequest(TimerRequest):
def _get_env(self, stdin):
env = super(ShutDownTimerRequest, self)._get_env(stdin)
env['PATH_INFO'] = TIMER_SERVICE_PATH + '/process_shutdown'
return env
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment