[server] Warn instead of failing when a looping task is registered and repo has no scheduler 3.25
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 29 Mar 2017 11:37:31 +0200
branch3.25
changeset 12111 cd069068a5ef
parent 12110 a9266a72f3e0
child 12112 0a54f49314f6
[server] Warn instead of failing when a looping task is registered and repo has no scheduler We should provide a way for client code to detect if they should register the looping task or not. See next patch for that.
cubicweb/server/repository.py
--- a/cubicweb/server/repository.py	Wed Mar 29 11:31:02 2017 +0200
+++ b/cubicweb/server/repository.py	Wed Mar 29 11:37:31 2017 +0200
@@ -407,8 +407,12 @@
         """
         if self.config.repairing:
             return
-        assert self._scheduler is not None, \
-            "This Repository is not intended to be used as a server"
+        if self._scheduler is None:
+            self.warning(
+                'looping task %s will not run in this process where repository '
+                'has no scheduler; use "cubicweb-ctl scheduler <appid>" to '
+                'have it running', func)
+            return
         event = utils.schedule_periodic_task(
             self._scheduler, interval, func, *args)
         self.info('scheduled periodic task %s (interval: %.2fs)',