[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.
--- 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)',