summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongyue Luo <zhongyue.nah@intel.com>2014-07-01 11:02:51 +0800
committerZhongyue Luo <zhongyue.nah@intel.com>2014-07-02 08:16:42 +0800
commite377393075c7758337bdadaecc600baea00d545f (patch)
tree6a8b7f81e2edd1914306713a958fc5017ba8d8ce
parentab5d5f1cdd225d8a8c90286e755215e0afc05c97 (diff)
downloadoslo-incubator-e377393075c7758337bdadaecc600baea00d545f.tar.gz
Changes calcuation of variable delay
In the loopingcall.FixedIntervalLoopingCall class, an warning is logged when 'delay' is equal or less than zero. Commonly delayed time is considered something over due from a deadline which is a positive value. Also a task delayed zero seconds is not considered delayed but finished on time. Therefore this patch fixes the calculation of the variable 'delay' and omits a warning log when 'delay' is zero Change-Id: I9dbae0838e6c03fa0eaa79e7332e650b02ed9c77
-rw-r--r--openstack/common/loopingcall.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/openstack/common/loopingcall.py b/openstack/common/loopingcall.py
index f9e13866..862f8b94 100644
--- a/openstack/common/loopingcall.py
+++ b/openstack/common/loopingcall.py
@@ -82,12 +82,12 @@ class FixedIntervalLoopingCall(LoopingCallBase):
end = _ts()
if not self._running:
break
- delay = interval + start - end
- if delay <= 0:
+ delay = end - start - interval
+ if delay > 0:
LOG.warn(_LW('task %(func_name)s run outlasted '
'interval by %(delay).2f sec'),
- {'func_name': repr(self.f), 'delay': -delay})
- greenthread.sleep(delay if delay > 0 else 0)
+ {'func_name': repr(self.f), 'delay': delay})
+ greenthread.sleep(-delay if delay < 0 else 0)
except LoopingCallDone as e:
self.stop()
done.send(e.retvalue)