[repository] fire 'server_shutdown' hooks before waiting for theads
authorDavid Douard <david.douard@logilab.fr>
Tue, 10 Apr 2012 17:07:03 +0200
changeset 8351 02f4f01375e8
parent 8350 e1c05bf6fdeb
child 8352 0e3b41118631
[repository] fire 'server_shutdown' hooks before waiting for theads This is required for threaded tasks that use the 'server_shutdown' hook to die properly, as for example the ZMQ server in an all-in-one configuration
server/repository.py
--- a/server/repository.py	Wed Apr 04 16:51:09 2012 +0200
+++ b/server/repository.py	Tue Apr 10 17:07:03 2012 +0200
@@ -429,13 +429,13 @@
         self.system_source.shutdown()
         if self._tasks_manager is not None:
             self._tasks_manager.stop()
+        if not (self.config.creating or self.config.repairing
+                or self.config.quick_start):
+            self.hm.call_hooks('server_shutdown', repo=self)
         for thread in self._running_threads:
             self.info('waiting thread %s...', thread.getName())
             thread.join()
             self.info('thread %s finished', thread.getName())
-        if not (self.config.creating or self.config.repairing
-                or self.config.quick_start):
-            self.hm.call_hooks('server_shutdown', repo=self)
         self.close_sessions()
         while not self._cnxsets_pool.empty():
             cnxset = self._cnxsets_pool.get_nowait()