service: add an on_shutdown() callback.

This commit is contained in:
David Wilson 2018-04-22 02:38:27 +01:00
parent 4c5e13bf87
commit 509ef14121
1 changed files with 7 additions and 0 deletions

View File

@ -143,6 +143,11 @@ class Service(object):
self.__class__.__name__,
)
def on_shutdown(self):
"""
Called by Pool.shutdown() once the last worker thread has exitted.
"""
def dispatch(self, args, msg):
raise NotImplementedError()
@ -307,6 +312,8 @@ class Pool(object):
self._select.close()
for th in self._threads:
th.join()
for service in self.services:
service.on_shutdown()
def _worker_run(self):
while True: