Esempio n. 1
0
        def _inner():
            if initial_delay:
                greenthread.sleep(initial_delay)

            try:
                while self._running:
                    start = timeutils.utcnow()
                    self.f(*self.args, **self.kw)
                    end = timeutils.utcnow()
                    if not self._running:
                        break
                    delay = interval - timeutils.delta_seconds(start, end)
                    if delay <= 0:
                        LOG.warn(_LW('task run outlasted interval by %s sec') %
                                 -delay)
                    greenthread.sleep(delay if delay > 0 else 0)
            except LoopingCallDone as e:
                self.stop()
                done.send(e.retvalue)
            except Exception:
                LOG.exception(_LE('in fixed duration looping call'))
                done.send_exception(*sys.exc_info())
                return
            else:
                done.send(True)
Esempio n. 2
0
 def inner(self, *args, **kwargs):
     LOG.debug("Entering %(cls)s.%(method)s",
               {'cls': self.__class__.__name__,
                'method': func.__name__})
     start = timeutils.utcnow()
     ret = func(self, *args, **kwargs)
     end = timeutils.utcnow()
     LOG.debug("Exiting %(cls)s.%(method)s. "
               "Spent %(duration)s sec. "
               "Return %(return)s",
               {'cls': self.__class__.__name__,
                'duration': timeutils.delta_seconds(start, end),
                'method': func.__name__,
                'return': ret})
     return ret
Esempio n. 3
0
 def inner(self, *args, **kwargs):
     LOG.debug("Entering %(cls)s.%(method)s", {
         'cls': self.__class__.__name__,
         'method': func.__name__
     })
     start = timeutils.utcnow()
     ret = func(self, *args, **kwargs)
     end = timeutils.utcnow()
     LOG.debug(
         "Exiting %(cls)s.%(method)s. "
         "Spent %(duration)s sec. "
         "Return %(return)s", {
             'cls': self.__class__.__name__,
             'duration': timeutils.delta_seconds(start, end),
             'method': func.__name__,
             'return': ret
         })
     return ret
Esempio n. 4
0
        def _inner():
            if initial_delay:
                greenthread.sleep(initial_delay)

            try:
                while self._running:
                    start = timeutils.utcnow()
                    self.f(*self.args, **self.kw)
                    end = timeutils.utcnow()
                    if not self._running:
                        break
                    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)