[repository] split repo initialization from starting looping task (closes #2204047)
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 20 Mar 2012 18:24:46 +0100
changeset 8321 b5d5a5630649
parent 8320 cd2d332b3063
child 8322 cb838b126b07
[repository] split repo initialization from starting looping task (closes #2204047) This separation highlights that two distinct operations are done. This is a step towards a full distinction between repo, server and looping tasks
server/repository.py
--- a/server/repository.py	Tue Mar 20 18:24:35 2012 +0100
+++ b/server/repository.py	Tue Mar 20 18:24:46 2012 +0100
@@ -353,7 +353,13 @@
             session.close()
         self.set_schema(appschema)
 
-    def start_looping_tasks(self):
+
+    def _prepare_startup(self):
+        """Prepare "Repository as a server" for startup.
+
+        * trigger server startup hook,
+        * register session clean up task.
+        """
         if not (self.config.creating or self.config.repairing
                 or self.config.quick_start):
             # call instance level initialisation hooks
@@ -362,7 +368,20 @@
             self.cleanup_session_time = self.config['cleanup-session-time'] or 60 * 60 * 24
             assert self.cleanup_session_time > 0
             cleanup_session_interval = min(60*60, self.cleanup_session_time / 3)
-            self.looping_task(cleanup_session_interval, self.clean_sessions)
+            self._tasks_manager.add_looping_task(cleanup_session_interval,
+                                                 self.clean_sessions)
+
+    def start_looping_tasks(self):
+        """Actual "Repository as a server" startup.
+
+        * trigger server startup hook,
+        * register session clean up task,
+        * start all tasks.
+
+        XXX Other startup related stuffs are done elsewhere. In Repository
+        XXX __init__ or in external codes (various server managers).
+        """
+        self._prepare_startup()
         self._tasks_manager.start()
 
     def looping_task(self, interval, func, *args):