Permalink
Browse files

Fixed a finally statement for Python 2.4 compatibility

git-svn-id: http://django-notification.googlecode.com/svn/trunk@160 590c3fc9-4838-0410-bb95-17a0c9b37ca9
  • Loading branch information...
1 parent 0f2d6f3 commit e04fdc9420306826b1b80623dfcad819813dc082 @jezdez jezdez committed Mar 30, 2009
Showing with 23 additions and 21 deletions.
  1. +23 −21 notification/engine.py
View
44 notification/engine.py
@@ -41,27 +41,29 @@ def send_all():
start_time = time.time()
try:
- for queued_batch in NoticeQueueBatch.objects.all():
- notices = pickle.loads(str(queued_batch.pickled_data).decode("base64"))
- for user, label, extra_context, on_site in notices:
- user = User.objects.get(pk=user)
- logging.info("emitting notice to %s" % user)
- # call this once per user to be atomic and allow for logging to
- # accurately show how long each takes.
- notification.send_now([user], label, extra_context, on_site)
- 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)
+ # nesting the try statement to be Python 2.4
+ try:
+ for queued_batch in NoticeQueueBatch.objects.all():
+ notices = pickle.loads(str(queued_batch.pickled_data).decode("base64"))
+ for user, label, extra_context, on_site in notices:
+ user = User.objects.get(pk=user)
+ logging.info("emitting notice to %s" % user)
+ # call this once per user to be atomic and allow for logging to
+ # accurately show how long each takes.
+ notification.send_now([user], label, extra_context, on_site)
+ 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()

0 comments on commit e04fdc9

Please sign in to comment.