[hooks] Return early in server_startup hooks if the repository has not tasks manager
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 28 Feb 2017 16:11:17 +0100
changeset 11986 4d414ecf8416
parent 11985 08398df041b4
child 11987 d432911e3c26
[hooks] Return early in server_startup hooks if the repository has not tasks manager
cubicweb/hooks/__init__.py
--- a/cubicweb/hooks/__init__.py	Tue Feb 28 16:05:00 2017 +0100
+++ b/cubicweb/hooks/__init__.py	Tue Feb 28 16:11:17 2017 +0100
@@ -29,6 +29,8 @@
     events = ('server_startup',)
 
     def __call__(self):
+        if self.repo._tasks_manager is None:
+            return
         # XXX use named args and inner functions to avoid referencing globals
         # which may cause reloading pb
         lifetime = timedelta(days=self.repo.config['keep-transaction-lifetime'])
@@ -49,6 +51,8 @@
     events = ('server_startup',)
 
     def __call__(self):
+        if self.repo._tasks_manager is None:
+            return
         def update_feeds(repo):
             # take a list to avoid iterating on a dictionary whose size may
             # change
@@ -71,6 +75,8 @@
     events = ('server_startup',)
 
     def __call__(self):
+        if self.repo._tasks_manager is None:
+            return
         def expire_dataimports(repo=self.repo):
             for uri, source in repo.sources_by_uri.items():
                 if (uri == 'system'