summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-03-31 11:29:33 +0200
committerIlya Etingof <etingof@gmail.com>2019-03-31 11:29:33 +0200
commit8a6dc6331cc667840166a25406057794f11fe8ec (patch)
treefe9f6827848c5a5a142c362325a6caffc89b301c
parent1de1055b2335d41ed46f9a6da3741aa4424adae4 (diff)
downloadpysnmp-git-8a6dc6331cc667840166a25406057794f11fe8ec.tar.gz
Update periodics call interval on timer resolution change
Fix to updates call interval of the existing periodic dispatcher jobs on call interval change (via .setTimerResolution())
-rw-r--r--CHANGES.txt4
-rw-r--r--pysnmp/carrier/base.py14
2 files changed, 17 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 24e490e0..8942df65 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,7 +2,9 @@
Revision 4.4.10, released 2019-04-XX
------------------------------------
-- Respect non-default timer resolution in asyncore main loop
+- Fix to respect non-default timer resolution in asyncore main loop
+- Fix to update call interval of the existing periodic dispatcher jobs
+ on interval change (via .setTimerResolution())
Revision 4.4.9, released 2019-02-09
-----------------------------------
diff --git a/pysnmp/carrier/base.py b/pysnmp/carrier/base.py
index 51a2d0b5..40b8d78a 100644
--- a/pysnmp/carrier/base.py
+++ b/pysnmp/carrier/base.py
@@ -36,6 +36,14 @@ class TimerCallable(object):
def __ge__(self, cbFun):
return self.__cbFun >= cbFun
+ @property
+ def interval(self):
+ return self.__callInterval
+
+ @interval.setter
+ def interval(self, callInterval):
+ self.__callInterval = callInterval
+
class AbstractTransportDispatcher(object):
def __init__(self):
@@ -151,6 +159,12 @@ class AbstractTransportDispatcher(object):
def setTimerResolution(self, timerResolution):
if timerResolution < 0.01 or timerResolution > 10:
raise error.CarrierError('Impossible timer resolution')
+
+ for timerCallable in self.__timerCallables:
+ if timerCallable.interval == self.__timerResolution:
+ # Update periodics for default resolutions
+ timerCallable.interval = timerResolution
+
self.__timerResolution = timerResolution
self.__timerDelta = timerResolution * 0.05