[repository, pyro] ensure we're still properly registered into pyro name server in a looping task (closes #1336002) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 11 Jan 2011 12:20:39 +0100
branchstable
changeset 6801 33952695295b
parent 6800 3f3d576b87d9
child 6802 ff9059e144f9
[repository, pyro] ensure we're still properly registered into pyro name server in a looping task (closes #1336002)
server/repository.py
--- a/server/repository.py	Tue Jan 11 12:19:36 2011 +0100
+++ b/server/repository.py	Tue Jan 11 12:20:39 2011 +0100
@@ -1350,8 +1350,9 @@
 
     # pyro handling ###########################################################
 
-    def pyro_register(self, host=''):
-        """register the repository as a pyro object"""
+    @property
+    @cached
+    def pyro_appid(self):
         from logilab.common import pyro_ext as pyro
         config = self.config
         appid = '%s.%s' % pyro.ns_group_and_id(
@@ -1359,13 +1360,27 @@
             config['pyro-ns-group'])
         # ensure config['pyro-instance-id'] is a full qualified pyro name
         config['pyro-instance-id'] = appid
-        daemon = pyro.register_object(self, appid,
-                                      daemonhost=config['pyro-host'],
-                                      nshost=config['pyro-ns-host'])
-        self.info('repository registered as a pyro object %s', appid)
+        return appid
+
+    def pyro_register(self, host=''):
+        """register the repository as a pyro object"""
+        from logilab.common import pyro_ext as pyro
+        daemon = pyro.register_object(self, self.pyro_appid,
+                                      daemonhost=self.config['pyro-host'],
+                                      nshost=self.config['pyro-ns-host'])
+        self.info('repository registered as a pyro object %s', self.pyro_appid)
         self.pyro_registered = True
+        # register a looping task to regularly ensure we're still registered
+        # into the pyro name server
+        self.looping_task(60*10, self._ensure_pyro_ns)
         return daemon
 
+    def _ensure_pyro_ns(self):
+        from logilab.common import pyro_ext as pyro
+        pyro.ns_reregister(self.pyro_appid, nshost=self.config['pyro-ns-host'])
+        self.info('repository re-registered as a pyro object %s',
+                  self.pyro_appid)
+
     # multi-sources planner helpers ###########################################
 
     @cached