diff options
Diffstat (limited to 'openstack/common/loopingcall.py')
| -rw-r--r-- | openstack/common/loopingcall.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/openstack/common/loopingcall.py b/openstack/common/loopingcall.py index 1d34519..be044d8 100644 --- a/openstack/common/loopingcall.py +++ b/openstack/common/loopingcall.py @@ -24,6 +24,7 @@ from eventlet import greenthread from openstack.common.gettextutils import _ from openstack.common import log as logging +from openstack.common import timeutils LOG = logging.getLogger(__name__) @@ -62,10 +63,16 @@ class LoopingCall(object): try: while self._running: + start = timeutils.utcnow() self.f(*self.args, **self.kw) + end = timeutils.utcnow() if not self._running: break - greenthread.sleep(interval) + delay = interval - timeutils.delta_seconds(start, end) + if delay <= 0: + LOG.warn(_('task run outlasted interval by %s sec') % + -delay) + greenthread.sleep(delay if delay > 0 else 0) except LoopingCallDone, e: self.stop() done.send(e.retvalue) |
