server/utils.py
branchstable
changeset 7823 5f145462e041
parent 7815 2a164a9cf81c
child 8317 9c59258e7798
child 8320 cd2d332b3063
--- a/server/utils.py	Thu Sep 22 10:02:17 2011 +0200
+++ b/server/utils.py	Thu Sep 22 10:02:25 2011 +0200
@@ -122,11 +122,12 @@
 
 class LoopTask(object):
     """threaded task restarting itself once executed"""
-    def __init__(self, interval, func, args):
+    def __init__(self, repo, interval, func, args):
         if interval <= 0:
             raise ValueError('Loop task interval must be > 0 '
                              '(current value: %f for %s)' % \
                              (interval, func_name(func)))
+        self.repo = repo
         self.interval = interval
         def auto_restart_func(self=self, func=func, args=args):
             restart = True
@@ -139,7 +140,7 @@
             except BaseException:
                 restart = False
             finally:
-                if restart:
+                if restart and not self.repo.shutting_down:
                     self.start()
         self.func = auto_restart_func
         self.name = func_name(func)