summaryrefslogtreecommitdiff
path: root/pysnmp/carrier/twisted/dispatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'pysnmp/carrier/twisted/dispatch.py')
-rw-r--r--pysnmp/carrier/twisted/dispatch.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/pysnmp/carrier/twisted/dispatch.py b/pysnmp/carrier/twisted/dispatch.py
index 77f5c168..ace0f6a4 100644
--- a/pysnmp/carrier/twisted/dispatch.py
+++ b/pysnmp/carrier/twisted/dispatch.py
@@ -28,9 +28,12 @@ class TwistedDispatcher(AbstractTransportDispatcher):
def __init__(self, *args, **kwargs):
AbstractTransportDispatcher.__init__(self)
+
self.__transportCount = 0
+
if 'timeout' in kwargs:
self.setTimerResolution(kwargs['timeout'])
+
self.loopingcall = task.LoopingCall(
lambda self=self: self.handleTimerTick(time.time())
)
@@ -44,22 +47,27 @@ class TwistedDispatcher(AbstractTransportDispatcher):
raise
except Exception:
- raise PySnmpError('reactor error: %s' % ';'.join(traceback.format_exception(*sys.exc_info())))
+ raise PySnmpError('reactor error: %s' % ';'.join(
+ traceback.format_exception(*sys.exc_info())))
# jobstarted/jobfinished might be okay as-is
- def registerTransport(self, tDomain, transport):
+ def registerTransport(self, transportDomain, transport):
if not self.loopingcall.running and self.getTimerResolution() > 0:
self.loopingcall.start(self.getTimerResolution(), now=False)
+
AbstractTransportDispatcher.registerTransport(
- self, tDomain, transport
+ self, transportDomain, transport
)
+
self.__transportCount += 1
- def unregisterTransport(self, tDomain):
- t = AbstractTransportDispatcher.getTransport(self, tDomain)
- if t is not None:
- AbstractTransportDispatcher.unregisterTransport(self, tDomain)
+ def unregisterTransport(self, transportDomain):
+ transport = AbstractTransportDispatcher.getTransport(
+ self, transportDomain)
+ if transport:
+ AbstractTransportDispatcher.unregisterTransport(
+ self, transportDomain)
self.__transportCount -= 1
# The last transport has been removed, stop the timeout