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): ...@@ -92,7 +92,7 @@ class TimerServer(threading.Thread):
interval = self.interval interval = self.interval
logger.info('Service ready.') logger.info('Service ready.')
request_class = TimerRequest
while 1: while 1:
time.sleep(interval) time.sleep(interval)
# send message to zope # send message to zope
...@@ -100,7 +100,9 @@ class TimerServer(threading.Thread): ...@@ -100,7 +100,9 @@ class TimerServer(threading.Thread):
out = StringIO() out = StringIO()
err = StringIO() err = StringIO()
response = TimerResponse(out, err) 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: except Exception:
logger.warn("Ignoring exception in run loop", exc_info=True) logger.warn("Ignoring exception in run loop", exc_info=True)
...@@ -186,3 +188,10 @@ class TimerRequest(HTTPRequest): ...@@ -186,3 +188,10 @@ class TimerRequest(HTTPRequest):
clone = HTTPRequest(None, environ, HTTPResponse(), clean=1) clone = HTTPRequest(None, environ, HTTPResponse(), clean=1)
clone['PARENTS'] = [self['PARENTS'][-1]] clone['PARENTS'] = [self['PARENTS'][-1]]
return clone 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