[repo] call server_startup event in start_looping_task the repo is fully started (registered in pyro for instance)
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 19 Mar 2010 14:42:35 +0100
changeset 4958 665eacdd8c50
parent 4957 25f20adba80f
child 4959 2cb79b8a1aea
[repo] call server_startup event in start_looping_task the repo is fully started (registered in pyro for instance)
devtools/testlib.py
server/repository.py
--- a/devtools/testlib.py	Fri Mar 19 10:10:18 2010 +0100
+++ b/devtools/testlib.py	Fri Mar 19 14:42:35 2010 +0100
@@ -207,6 +207,7 @@
     def _build_repo(cls):
         cls.repo, cls.cnx = devtools.init_test_database(config=cls.config)
         cls.init_config(cls.config)
+        cls.repo.hm.call_hooks('server_startup', repo=cls.repo)
         cls.vreg = cls.repo.vreg
         cls._orig_cnx = cls.cnx
         cls.config.repository = lambda x=None: cls.repo
--- a/server/repository.py	Fri Mar 19 10:10:18 2010 +0100
+++ b/server/repository.py	Fri Mar 19 14:42:35 2010 +0100
@@ -219,11 +219,6 @@
             self._available_pools.put_nowait(self.pools[-1])
         self._shutting_down = False
         self.hm = self.vreg['hooks']
-        if not (config.creating or config.repairing):
-            # call instance level initialisation hooks
-            self.hm.call_hooks('server_startup', repo=self)
-            # register a task to cleanup expired session
-            self.looping_task(config['session-time']/3., self.clean_sessions)
 
     # internals ###############################################################
 
@@ -272,6 +267,11 @@
         self.set_schema(appschema)
 
     def start_looping_tasks(self):
+        if not (self.config.creating or self.config.repairing):
+            # call instance level initialisation hooks
+            self.hm.call_hooks('server_startup', repo=self)
+            # register a task to cleanup expired session
+            self.looping_task(self.config['session-time']/3., self.clean_sessions)
         assert isinstance(self._looping_tasks, list), 'already started'
         for i, (interval, func, args) in enumerate(self._looping_tasks):
             self._looping_tasks[i] = task = utils.LoopTask(interval, func, args)