only catch s3 and db errors in build-dvla-file-for-job

this reduces the amount of error messages we log (we'll no longer log
at error level when build-dvla-file-for-job retries while waiting for
the task to finish), and make sure we retry in those cases above - db
or s3 having temporary troubl
This commit is contained in:
Leo Hemsted
2017-11-27 15:11:58 +00:00
parent b6ac7f074d
commit 1e4a480298
2 changed files with 26 additions and 13 deletions

View File

@@ -18,6 +18,8 @@ from requests import (
RequestException
)
from sqlalchemy.exc import SQLAlchemyError
from botocore.exceptions import ClientError as BotoClientError
from app import (
create_uuid,
create_random_identifier,
@@ -325,11 +327,11 @@ def build_dvla_file(self, job_id):
else:
msg = "All notifications for job {} are not persisted".format(job_id)
current_app.logger.info(msg)
self.retry(queue=QueueNames.RETRY, exc=Exception(msg))
except Exception as e:
# ? should this retry?
self.retry(queue=QueueNames.RETRY)
# specifically don't catch celery.retry errors
except (SQLAlchemyError, BotoClientError):
current_app.logger.exception("build_dvla_file threw exception")
raise e
self.retry(queue=QueueNames.RETRY)
@notify_celery.task(bind=True, name='update-letter-job-to-sent')