From 920cbcab78f90013465beadbaf7421db1d2c220e Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Sat, 29 Dec 2018 10:40:01 +0100 Subject: Fix hlapi/v1arch request timeout The retrying mechanism never worked, apparently. --- pysnmp/carrier/asyncore/dispatch.py | 3 +-- pysnmp/carrier/base.py | 2 +- pysnmp/hlapi/v1arch/dispatch.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'pysnmp') diff --git a/pysnmp/carrier/asyncore/dispatch.py b/pysnmp/carrier/asyncore/dispatch.py index a88bd673..4cdd61bf 100644 --- a/pysnmp/carrier/asyncore/dispatch.py +++ b/pysnmp/carrier/asyncore/dispatch.py @@ -16,7 +16,6 @@ from pysnmp.error import PySnmpError class AsyncoreDispatcher(AbstractTransportDispatcher): def __init__(self): self.__sockMap = {} # use own map for MT safety - self.timeout = 0.5 AbstractTransportDispatcher.__init__(self) def getSocketMap(self): @@ -42,7 +41,7 @@ class AsyncoreDispatcher(AbstractTransportDispatcher): def runDispatcher(self, timeout=0.0): while self.jobsArePending() or self.transportsAreWorking(): try: - loop(timeout and timeout or self.timeout, + loop(timeout or self.getTimerResolution(), use_poll=True, map=self.__sockMap, count=1) except KeyboardInterrupt: raise diff --git a/pysnmp/carrier/base.py b/pysnmp/carrier/base.py index aedd42eb..ef6485c0 100644 --- a/pysnmp/carrier/base.py +++ b/pysnmp/carrier/base.py @@ -45,7 +45,7 @@ class AbstractTransportDispatcher(object): self.__recvCallables = {} self.__timerCallables = [] self.__ticks = 0 - self.__timerResolution = 0.5 + self.__timerResolution = 0.1 self.__timerDelta = self.__timerResolution * 0.05 self.__nextTime = 0 self.__routingCbFun = None diff --git a/pysnmp/hlapi/v1arch/dispatch.py b/pysnmp/hlapi/v1arch/dispatch.py index 0c222281..09041eb2 100644 --- a/pysnmp/hlapi/v1arch/dispatch.py +++ b/pysnmp/hlapi/v1arch/dispatch.py @@ -141,8 +141,8 @@ class AbstractSnmpDispatcher(object): return wholeMsg def _timerCb(self, timeNow): - for requestId, stateInfo in self._pendingReqs.items(): - if stateInfo['timestamp'] < timeNow: + for requestId, stateInfo in tuple(self._pendingReqs.items()): + if stateInfo['timestamp'] > timeNow: continue retries = stateInfo['retries'] -- cgit v1.2.1