diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-02-26 08:56:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-26 08:56:24 +0100 |
commit | 3f2f132a9fdf7a48ec6131d5498145dded3cfcad (patch) | |
tree | 63e6170b35f6b392bf2e3d3feb6996b886e4d36f /pysnmp/carrier/twisted/dispatch.py | |
parent | 2ad26f8bfef0e39b3789d9e6d4fcbf76820c9867 (diff) | |
download | pysnmp-git-3f2f132a9fdf7a48ec6131d5498145dded3cfcad.tar.gz |
PEP-8 long lines and dunders (#245)
This patch massively reformats the whole codebase mainly wrapping
long lines and eliminating dundered private attributes.
Diffstat (limited to 'pysnmp/carrier/twisted/dispatch.py')
-rw-r--r-- | pysnmp/carrier/twisted/dispatch.py | 22 |
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 |