summaryrefslogtreecommitdiff
path: root/pysnmp/carrier/base.py
diff options
context:
space:
mode:
authorelie <elie>2013-03-15 20:50:24 +0000
committerelie <elie>2013-03-15 20:50:24 +0000
commit7fc7d79936e7abd197932bec2b304e046581ea6b (patch)
tree4bb1a694dc4ae884b8f87281a09606694db47fb2 /pysnmp/carrier/base.py
parent5732e9f42bb48faaf9f43282000547016ce87747 (diff)
downloadpysnmp-git-7fc7d79936e7abd197932bec2b304e046581ea6b.tar.gz
fix of rounding error to base I/O dispatcher's next timer call calculation
Diffstat (limited to 'pysnmp/carrier/base.py')
-rw-r--r--pysnmp/carrier/base.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pysnmp/carrier/base.py b/pysnmp/carrier/base.py
index 4aa01052..bb2424e4 100644
--- a/pysnmp/carrier/base.py
+++ b/pysnmp/carrier/base.py
@@ -27,6 +27,7 @@ class AbstractTransportDispatcher:
self.__timerCallables = []
self.__ticks = 0
self.__timerResolution = 0.5
+ self.__timerDelta = self.__timerResolution * 0.05
self.__nextTime = 0
def _cbFun(self, incomingTransport, transportAddress, incomingMessage):
@@ -112,18 +113,19 @@ class AbstractTransportDispatcher:
if timerResolution < 0.01 or timerResolution > 10:
raise error.CarrierError('Impossible timer resolution')
self.__timerResolution = timerResolution
+ self.__timerDelta = timerResolution * 0.05
def getTimerTicks(self): return self.__ticks
def handleTimerTick(self, timeNow):
if self.__nextTime == 0: # initial initialization
- self.__nextTime = timeNow + self.__timerResolution
+ self.__nextTime = timeNow + self.__timerResolution - self.__timerDelta
- if self.__nextTime > timeNow:
+ if self.__nextTime >= timeNow:
return
self.__ticks += 1
- self.__nextTime = timeNow + self.__timerResolution
+ self.__nextTime = timeNow + self.__timerResolution - self.__timerDelta
for timerCallable in self.__timerCallables:
timerCallable(timeNow)