dont try and send broadccast event if it's already in technical-failure

this gives us an option to manually set a status in the database and
avoid things being stuck in a retry loop forever
This commit is contained in:
Leo Hemsted
2021-02-05 12:46:23 +00:00
parent 0ddebc63a8
commit d582e35471
2 changed files with 13 additions and 2 deletions

View File

@@ -51,6 +51,15 @@ def check_provider_message_should_send(broadcast_event, provider):
4. If you need to re-send this task off again, you'll need to run the following command on paas:
`send_broadcast_provider_message.apply_async(args=(broadcast_event_id, provider), queue=QueueNames.BROADCASTS)`
"""
current_provider_message = broadcast_event.get_provider_message(provider)
# if this is the first time a task is being executed, it won't have a provider message yet
if current_provider_message and current_provider_message.status == BroadcastProviderMessageStatus.TECHNICAL_FAILURE:
raise CBCProxyFatalException(
f'Cannot send broadcast_event {broadcast_event.id} ' +
f'to provider {provider}: ' +
f'It is already in status technical-failure'
)
if broadcast_event.transmitted_finishes_at < datetime.utcnow():
# TODO: This should be a different kind of exception to distinguish "We should know something went wrong, but
# no immediate action" from "We need to fix this immediately"