Skip to content

Commit

Permalink
Merge pull request #1492 from GSA/notify-api-1487
Browse files Browse the repository at this point in the history
remove tasks from redis after they complete
  • Loading branch information
ccostino authored Dec 20, 2024
2 parents 7c7f96d + 6134530 commit 786b661
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class Config(object):

CELERY = {
"worker_max_tasks_per_child": 500,
"task_ignore_result": True,
"result_persistent": False,
"broker_url": REDIS_URL,
"broker_transport_options": {
"visibility_timeout": 310,
Expand Down

0 comments on commit 786b661

Please sign in to comment.