forbid looping tasks with an interval of 0 stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Sat, 29 May 2010 09:57:02 +0000
branchstable
changeset 5602 277b15d6d3ed
parent 5601 92cf309672ca
child 5603 d8d9f4ec252d
forbid looping tasks with an interval of 0 This severly harm the server, and generally are the result of a baaad configuration file. We want to stop the server asap when this is detected to give people a chance to fix the configuration.
server/utils.py
--- a/server/utils.py	Sat May 29 09:54:07 2010 +0000
+++ b/server/utils.py	Sat May 29 09:57:02 2010 +0000
@@ -123,6 +123,10 @@
 class LoopTask(object):
     """threaded task restarting itself once executed"""
     def __init__(self, interval, func, args):
+        if interval <= 0:
+            raise ValueError('Loop task interval must be > 0 '
+                             '(current value: %f for %s)' % \
+                             (interval, func.__name__))
         self.interval = interval
         def auto_restart_func(self=self, func=func, args=args):
             try: