Skip to content
Browse files

Ignore non existing users in async notices

Signed-off-by: Brian Rosner <brosner@gmail.com>
  • Loading branch information...
1 parent d726bb7 commit 5f299024a77857318b5d993587b894c0b9c1ace6 @diox diox committed with brosner Apr 26, 2010
Showing with 9 additions and 5 deletions.
  1. +9 −5 notification/engine.py
View
14 notification/engine.py
@@ -46,11 +46,15 @@ def send_all():
for queued_batch in NoticeQueueBatch.objects.all():
notices = pickle.loads(str(queued_batch.pickled_data).decode("base64"))
for user, label, extra_context, on_site, sender in notices:
- user = User.objects.get(pk=user)
- logging.info("emitting notice %s to %s" % (label, 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, sender)
+ try:
+ user = User.objects.get(pk=user)
+ logging.info("emitting notice %s to %s" % (label, 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, sender)
+ except User.DoesNotExist:
+ # Ignore deleted users, just warn about them
+ logging.warning("not emitting notice %s to user %s since it does not exist" % (label, user))
sent += 1
queued_batch.delete()
batches += 1

0 comments on commit 5f29902

Please sign in to comment.
Something went wrong with that request. Please try again.