[Twisted-Python] [cpushare at cpushare.com: CPUShare Exception]
Andrea Arcangeli
andrea at cpushare.com
Thu Jul 7 08:23:13 MDT 2005
On Thu, Jul 07, 2005 at 08:48:59AM -0400, glyph at divmod.com wrote:
> It seems like you might want to filter more than just OpenSSL.SSL.Error ;).
very likely ;), but I guess I can wait until some harmless annoyance
trigger like in this case.
The number of emails the server sends me has a maximum of 10, to avoid
getting the same exception too many times (and the max number of sms is
1). So even something goes wrong and I'm on vacation I don't risk to
fill the inbox ;)
> eventDict['failure'] is a twisted.python.failure.Failure object; see the
> API docs or the code for that class for details on introspecting them
> (they're designed to be easier to introspect than Python tuples).
>
> For your particular request:
>
> if not eventDict['failure'].check(OpenSSL.SSL.Error):
> send_exception(...)
cool, I updated it like this.
from OpenSSL import SSL
from twisted.python import log
# local
from cpushare.mail import send_exception
class cpushare_logging_observer_class(object):
def __init__(self, factory):
self.factory = factory
def start(self):
if self.factory.production:
log.addObserver(self.emit)
def stop(self):
if self.factory.production:
log.removeObserver(self.emit)
def emit(self, eventDict):
edm = eventDict['message']
if not edm:
if eventDict['isError'] and eventDict.has_key('failure'):
failure = eventDict['failure']
if not failure.check(SSL.Error):
send_exception(failure)
Thanks.
More information about the Twisted-Python
mailing list