Add further error checking to the Reddit tasks, gracefully handle issues

This commit is contained in:
2011-01-20 09:17:16 +00:00
parent 924f6daebf
commit 1696ac0d43

View File

@@ -14,8 +14,8 @@ class send_reddit_message(Task):
logger = self.get_logger(**kwargs)
logger.info("Sending Reddit message to %s" % to)
ib = Inbox(username=settings.REDDIT_USER, password=settings.REDDIT_PASSWORD)
try:
ib = Inbox(username=settings.REDDIT_USER, password=settings.REDDIT_PASSWORD)
ib.send(to, subject, message)
except (HTTPError, URLError), exc:
logger.error("Error sending message, queueing for retry")
@@ -30,13 +30,6 @@ def process_validations():
logger = process_validations.get_logger()
try:
inbox = Inbox(settings.REDDIT_USER, settings.REDDIT_PASSWORD)
except (HTTPError, URLError), exc:
logger.error("Error with Reddit, aborting.")
return
except LoginError, exc:
logger.error("Error logging into Reddit")
return
for msg in inbox:
if not msg.was_comment:
try:
@@ -47,4 +40,9 @@ def process_validations():
acc.save()
except RedditAccount.DoesNotExist:
continue
except (HTTPError, URLError), exc:
logger.error("Error with Reddit, aborting.")
return
except LoginError, exc:
logger.error("Error logging into Reddit")
return