# HG changeset patch # User Julien Cristau # Date 1366798212 -7200 # Node ID da2007002dca99c6d1cdff7dea51f956c8182d5d # Parent 2dd134a8699676f7d674e1516072207a610c16e8 [task] allow negative intervals for add_looping_task (closes #2818280) Instead of rejecting values < 0 with a ValueError, we ignore tasks with a negative interval. This introduce a simple way to disable task from configuration. diff -r 2dd134a86996 -r da2007002dca doc/3.17.rst --- a/doc/3.17.rst Wed Apr 24 11:58:49 2013 +0200 +++ b/doc/3.17.rst Wed Apr 24 12:10:12 2013 +0200 @@ -32,7 +32,8 @@ ``ActualNotificationOp`` the new operation use the more efficient *data* idiom. -* Looping task can now have a ``0`` interval. +* Looping task can now have a interval <= ``0``. Negative interval disable the + looping task entirely. Deprecation diff -r 2dd134a86996 -r da2007002dca server/utils.py --- a/server/utils.py Wed Apr 24 11:58:49 2013 +0200 +++ b/server/utils.py Wed Apr 24 12:10:12 2013 +0200 @@ -219,7 +219,13 @@ def add_looping_task(self, interval, func, *args): """register a function to be called every `interval` seconds. + + If interval is negative, no looping task is registered. """ + if interval < 0: + self.debug('looping task %s ignored due to interval %f < 0', + func_name(func), interval) + return task = LoopTask(self, interval, func, args) if self.running: self._start_task(task)