From 7ca9116e370d3a82dbb48c9d6aa4492cab44e6b5 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 14 Mar 2017 23:56:52 +0800 Subject: [PATCH] Trigger before_stop before closing server, after_stop before closing loop --- sanic/worker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sanic/worker.py b/sanic/worker.py index 4e70f10d..c0825ac7 100644 --- a/sanic/worker.py +++ b/sanic/worker.py @@ -44,13 +44,13 @@ class GunicornWorker(base.Worker): self.loop) self.loop.run_until_complete(self._check_alive()) finally: - trigger_events(self._server_settings.get('before_stop', []), - self.loop) - self.loop.close() trigger_events(self._server_settings.get('after_stop', []), self.loop) + self.loop.close() async def close(self): + trigger_events(self._server_settings.get('before_stop', []), + self.loop) if self.servers: # stop accepting connections self.log.info("Stopping server: %s, connections: %s",