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
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user