exception re-raising improved at asynsock/twisted dispatchers so that

original traceback is preserved and reported
pull/45/head
elie 2013-06-26 15:44:44 +00:00
parent 2ea76b7bd3
commit 64824fd736
3 changed files with 10 additions and 7 deletions

View File

@ -27,8 +27,8 @@ Revision 4.2.5rc2
at once. Although RFC2576 does not suggest error-status -> v2c exception
translation, historically pysnmp used to perform it for a long time so we
can't easily stop doing that.
- Exception re-raising improved at MibInstrumController.flipFlopFsm() so
that original traceback is preserved.
- Exception re-raising improved at MibInstrumController.flipFlopFsm() and
asynsock/twisted dispatchers so that original traceback is preserved.
- The snmpCommunityTable row selection improved to follow RFC2576, clause
5.2.1.
- Asyncore-based dispatcher attempts to use poll() whenever available

View File

@ -1,6 +1,7 @@
# Implements I/O over asynchronous sockets
from time import time
from sys import exc_info
from traceback import format_exception
from asyncore import socket_map
from asyncore import loop
from pysnmp.carrier.base import AbstractTransportDispatcher
@ -37,5 +38,5 @@ class AsynsockDispatcher(AbstractTransportDispatcher):
except KeyboardInterrupt:
raise
except:
raise PySnmpError('poll error: %s' % exc_info()[1])
raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())))
self.handleTimerTick(time())

View File

@ -8,10 +8,10 @@
#
# Description: Transport dispatcher based on twisted.internet.reactor
#
import sys, time
import sys, time, traceback
from twisted.internet import reactor, task
from pysnmp.carrier.base import AbstractTransportDispatcher
from pysnmp.carrier import error
from pysnmp.error import PySnmpError
class TwistedDispatcher(AbstractTransportDispatcher):
"""TransportDispatcher based on twisted.internet.reactor"""
@ -28,8 +28,10 @@ class TwistedDispatcher(AbstractTransportDispatcher):
if not reactor.running:
try:
reactor.run()
except Exception:
raise error.CarrierError(sys.exc_info()[1])
except KeyboardInterrupt:
raise
except:
raise PySnmpError('reactor error: %s' % ';'.join(traceback.format_exception(*sys.exc_info())))
# jobstarted/jobfinished might be okay as-is