cubicweb/server/repository.py
branch3.25
changeset 12112 0a54f49314f6
parent 12111 cd069068a5ef
child 12130 4d874c2fbb5f
--- a/cubicweb/server/repository.py	Wed Mar 29 11:37:31 2017 +0200
+++ b/cubicweb/server/repository.py	Wed Mar 29 11:45:19 2017 +0200
@@ -383,6 +383,12 @@
                 raise Exception('Is the database initialised ? (cause: %s)' % ex)
         return appschema
 
+    def has_scheduler(self):
+        """Return True if the repository has a scheduler attached and is able
+        to register looping tasks.
+        """
+        return self._scheduler is not None
+
     def run_scheduler(self):
         """Start repository scheduler after preparing the repository for that.
 
@@ -392,7 +398,7 @@
         XXX Other startup related stuffs are done elsewhere. In Repository
         XXX __init__ or in external codes (various server managers).
         """
-        assert self._scheduler is not None, \
+        assert self.has_scheduler(), \
             "This Repository is not intended to be used as a server"
         self.info(
             'starting repository scheduler with tasks: %s',
@@ -407,7 +413,7 @@
         """
         if self.config.repairing:
             return
-        if self._scheduler is None:
+        if not self.has_scheduler():
             self.warning(
                 'looping task %s will not run in this process where repository '
                 'has no scheduler; use "cubicweb-ctl scheduler <appid>" to '