summaryrefslogtreecommitdiff
path: root/pysnmp/carrier/base.py
diff options
context:
space:
mode:
authorelie <elie>2011-11-27 08:10:43 +0000
committerelie <elie>2011-11-27 08:10:43 +0000
commit6051a4d86db92155dd73f54c0962613fe575f43e (patch)
tree9435dab404953063f67565c2fc3bc20fca159cb2 /pysnmp/carrier/base.py
parentf7cdcd408b82a17831bb9a77159496b9638abc3d (diff)
downloadpysnmp-git-6051a4d86db92155dd73f54c0962613fe575f43e.tar.gz
transport dispatcher now provides its own time expressed in
fractions of second. SNMP engine uses this notion of time for handling requests timeout to make packet flow time bound
Diffstat (limited to 'pysnmp/carrier/base.py')
-rw-r--r--pysnmp/carrier/base.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/pysnmp/carrier/base.py b/pysnmp/carrier/base.py
index 57010435..cc0fdd7e 100644
--- a/pysnmp/carrier/base.py
+++ b/pysnmp/carrier/base.py
@@ -25,7 +25,10 @@ class AbstractTransportDispatcher:
self.__jobs = {}
self.__recvCbFun = None
self.__timerCallables = []
-
+ self.__ticks = 0
+ self.__timerResolution = 0.5
+ self.__lastTime = 0
+
def _cbFun(self, incomingTransport, transportAddress, incomingMessage):
for name, transport in self.__transports.items():
if transport is incomingTransport:
@@ -96,7 +99,22 @@ class AbstractTransportDispatcher:
'No suitable transport domain for %s' % (transportDomain,)
)
+ def getTimerResolution(self):
+ return self.__timerResolution
+ def setTimerResolution(self, timerResolution):
+ if timerResolution < 0.01 or timerResolution > 10:
+ raise error.CarrierError('Impossible timer resolution')
+ self.__timerResolution = timerResolution
+
+ def getTimerTicks(self): return self.__ticks
+
def handleTimerTick(self, timeNow):
+ if self.__lastTime + self.__timerResolution > timeNow:
+ return
+
+ self.__ticks += 1
+ self.__lastTime = timeNow
+
for timerCallable in self.__timerCallables:
timerCallable(timeNow)