Author: brosner
Date: Wed Dec 10 12:39:06 2008
New Revision: 119
Modified:
trunk/notification/engine.py
Log:
Catch exceptions while processing the queue and handle them nicely and
e-mail them to ADMINS.
Modified: trunk/notification/engine.py
==============================================================================
--- trunk/notification/engine.py (original)
+++ trunk/notification/engine.py Wed Dec 10 12:39:06 2008
@@ -1,6 +1,8 @@
+import sys
import time
import logging
+import traceback
try:
import cPickle as pickle
@@ -8,7 +10,9 @@
import pickle
from django.conf import settings
+from django.core.mail import mail_admins
from django.contrib.auth.models import User
+from django.contrib.sites.models import Site
from lockfile import FileLock, AlreadyLocked, LockTimeout
@@ -48,6 +52,16 @@
sent += 1
queued_batch.delete()
batches += 1
+ except:
+ # get the exception
+ exc_class, e, t = sys.exc_info()
+ # email people
+ current_site = Site.objects.get_current()
+ subject = "[%s emit_notices] %r" % (current_site.name, e)
+ message = "%s" %
("\n".join(traceback.format_exception(*sys.exc_info())),)
+ mail_admins(subject, message, fail_silently=True)
+ # log it as critical
+ logging.critical("an exception occurred: %r" % e)
finally:
logging.debug("releasing lock...")
lock.release()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---