[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

authorDavid Douard <david.douard@logilab.fr>
changeset02f4f01375e8
branchdefault
phasepublic
hiddenno
parent revision#e1c05bf6fdeb [zmq] Implement a ZMQ-based Repository (closes #2290125)
child revision#0e3b41118631 [dbapi] add possibility to connect to a remote ZMQRepository (closes #2290126)
files modified by this revision
server/repository.py
# HG changeset patch
# User David Douard <david.douard@logilab.fr>
# Date 1334070423 -7200
# Tue Apr 10 17:07:03 2012 +0200
# Node ID 02f4f01375e894a8f9f7df0cb44a9fea4fca091b
# Parent e1c05bf6fdeb6aa0f615fd5a719697eb4d0d2047
[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

diff --git a/server/repository.py b/server/repository.py
@@ -427,17 +427,17 @@
1          assert not self.shutting_down, 'already shutting down'
2          self.shutting_down = True
3          self.system_source.shutdown()
4          if self._tasks_manager is not None:
5              self._tasks_manager.stop()
6 +        if not (self.config.creating or self.config.repairing
7 +                or self.config.quick_start):
8 +            self.hm.call_hooks('server_shutdown', repo=self)
9          for thread in self._running_threads:
10              self.info('waiting thread %s...', thread.getName())
11              thread.join()
12              self.info('thread %s finished', thread.getName())
13 -        if not (self.config.creating or self.config.repairing
14 -                or self.config.quick_start):
15 -            self.hm.call_hooks('server_shutdown', repo=self)
16          self.close_sessions()
17          while not self._cnxsets_pool.empty():
18              cnxset = self._cnxsets_pool.get_nowait()
19              try:
20                  cnxset.close(True)