Skip to content

Commit

Permalink
Reschedule rate limited telegram task instead of retry
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasb committed Oct 15, 2024
1 parent 287bfcc commit e32cd97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engine/apps/alerts/tasks/notify_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,12 @@ def perform_notification(log_record_pk, use_default_notification_policy_fallback
try:
TelegramToUserConnector.notify_user(user, alert_group, notification_policy)
except RetryAfter as e:
task_logger.exception(f"Telegram API rate limit exceeded. Retry after {e.retry_after} seconds.")
countdown = getattr(e, "retry_after", 3)
raise perform_notification.retry(
(log_record_pk, use_default_notification_policy_fallback), countdown=countdown, exc=e
perform_notification.apply_async(
(log_record_pk, use_default_notification_policy_fallback), countdown=countdown
)
return

elif notification_channel == UserNotificationPolicy.NotificationChannel.SLACK:
# TODO: refactor checking the possibility of sending a notification in slack
Expand Down

0 comments on commit e32cd97

Please sign in to comment.