Skip to content

Commit

Permalink
Fixing IntegrityError problems, again.
Browse files Browse the repository at this point in the history
Signed-off-by: Cliff Hill <[email protected]>
  • Loading branch information
xlorepdarkhelm committed Dec 27, 2024
1 parent 45a1492 commit f1e8ff3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ def save_sms(self, service_id, notification_id, encrypted_notification, sender_i
f"service not allowed to send for job_id {notification.get('job', None)}, aborting"
)
)
current_app.logger.debug(
"SMS {} failed as restricted service".format(notification_id)
)
current_app.logger.debug(f"SMS {notification_id} failed as restricted service")
return

try:
Expand Down Expand Up @@ -244,11 +242,12 @@ def save_sms(self, service_id, notification_id, encrypted_notification, sender_i
reply_to_text=reply_to_text,
)
except IntegrityError:
if notification_exists(notification_id):
saved_notification = get_notification(notification_id)

else:
raise
current_app.logger.warning(
f"{NotificationType.SMS}: {notification_id} already exists."
)
# If we don't have the return statement here, we will fall through and end
# up retrying because IntegrityError is a subclass of SQLAlchemyError
return

# Kick off sns process in provider_tasks.py
sn = saved_notification
Expand Down

0 comments on commit f1e8ff3

Please sign in to comment.