Allow retry exception to propagate from ses callback task

Celery `self.retry` raises an exception to communicate that the task
needs to be retried. Since our ses task is wrapped in a catch-all
except block it logs that exception as an error before retrying.

Handling Retry class separately allows us to raise it without logging
the traceback.
This commit is contained in:
Alexey Bezhan
2019-02-25 13:25:50 +00:00
parent 3271a567b8
commit c2e15d4ee2

View File

@@ -1,6 +1,7 @@
from datetime import datetime, timedelta
import iso8601
from celery.exceptions import Retry
from flask import current_app, json
from notifications_utils.statsd_decorators import statsd
from sqlalchemy.orm.exc import NoResultFound
@@ -75,6 +76,9 @@ def process_ses_results(self, response):
return True
except Retry:
raise
except Exception as e:
current_app.logger.exception('Error processing SES results: {}'.format(type(e)))
self.retry(queue=QueueNames.RETRY)