remove tasks from redis after they complete

This commit is contained in:
Kenneth Kehl
2024-12-18 14:09:22 -08:00
parent 5a6980f31e
commit cfe9b11cf6
2 changed files with 11 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import json
from celery.signals import task_postrun
from flask import current_app
from requests import HTTPError, RequestException, request
from sqlalchemy.exc import IntegrityError, SQLAlchemyError
@@ -170,6 +171,13 @@ def __total_sending_limits_for_job_exceeded(service, job, job_id):
return True
@task_postrun.connect
def log_task_ejection(sender=None, task_id=None, **kwargs):
current_app.logger.info(
f"Task {task_id} ({sender.name if sender else 'unknown_task'}) has been completed and removed"
)
@notify_celery.task(bind=True, name="save-sms", max_retries=2, default_retry_delay=600)
def save_sms(self, service_id, notification_id, encrypted_notification, sender_id=None):
"""Persist notification to db and place notification in queue to send to sns."""