handling throttling exception

This commit is contained in:
Kenneth Kehl
2024-07-19 07:48:55 -07:00
parent 8124d981d8
commit 56c87e9611
2 changed files with 17 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ import json
import os
from datetime import timedelta
from botocore.exceptions import ClientError
from flask import current_app
from sqlalchemy.orm.exc import NoResultFound
@@ -62,6 +63,21 @@ def check_sms_delivery_receipt(self, message_id, notification_id, sent_at):
provider_response=provider_response,
)
raise self.retry(exc=ntfe)
except ClientError as err:
# Probably a ThrottlingException but could be something else
error_code = err.response["Error"]["Code"]
provider_response = (
f"{error_code} while checking sms receipt -- still looking"
)
status = "pending"
carrier = ""
update_notification_status_by_id(
notification_id,
status,
carrier=carrier,
provider_response=provider_response,
)
raise self.retry(exc=err)
if status == "success":
status = NotificationStatus.DELIVERED