From 195873c7b719bba1d7df87f42957f58f4f90b21c Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Wed, 26 Jun 2024 16:33:04 +0330 Subject: [PATCH] feat: trying garbage collection in celery post-run might not change anything but worth trying. --- celery_app/tasks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/celery_app/tasks.py b/celery_app/tasks.py index 3da5f62..8667231 100644 --- a/celery_app/tasks.py +++ b/celery_app/tasks.py @@ -4,6 +4,7 @@ import os from typing import Any +from celery.signals import task_postrun from celery_app.server import app from celery_app.utils.fire_event import job_send from dotenv import load_dotenv @@ -122,4 +123,8 @@ def ask_question_auto_search( content=response_payload, ) + +@task_postrun.connect +def task_postrun_handler(sender=None, **kwargs): + # Trigger garbage collection after each task gc.collect()