From c3fc48fddc9b4c5276460ca8751d6011e6fa053a Mon Sep 17 00:00:00 2001 From: i701 Date: Fri, 11 Jul 2025 09:53:03 +0500 Subject: [PATCH] =?UTF-8?q?refactor(tasks):=20update=20job=20scheduling=20?= =?UTF-8?q?frequency=20and=20reduce=20max=20hours=20for=20old=20job=20remo?= =?UTF-8?q?val=20=F0=9F=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/tasks.py | 10 ++-------- api/views.py | 2 -- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/api/tasks.py b/api/tasks.py index c5d894e..b4bbfa1 100644 --- a/api/tasks.py +++ b/api/tasks.py @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) env.read_env(os.path.join(BASE_DIR, ".env")) -@app.periodic(cron="0 4 * * *") +@app.periodic(cron="0 * * * *") # every 1 hour @app.task( queueing_lock="remove_old_jobs", pass_context=True, @@ -28,19 +28,13 @@ async def remove_old_jobs(context, timestamp): return await builtin_tasks.remove_old_jobs( context, queue="heavy_tasks", - max_hours=24, + max_hours=1, remove_failed=True, remove_cancelled=True, remove_aborted=True, ) -@app.task -def add(x, y): - logger.info(f"Executing test background task with {x} and {y}") - return x + y - - @app.periodic( cron="0 0 */28 * *", queue="heavy_tasks", periodic_id="deactivate_expired_devices" ) # type: ignore diff --git a/api/views.py b/api/views.py index 98e5ecf..bc1c37f 100644 --- a/api/views.py +++ b/api/views.py @@ -31,7 +31,6 @@ from typing import cast, Dict, Any from django.core.mail import send_mail from django.db.models import Q from api.notifications import send_otp -from .tasks import add from .utils import check_person_api_verification # local apps import @@ -60,7 +59,6 @@ class ErrorMessages: @api_view(["GET"]) def healthcheck(request): - add.defer(1, 2) return Response({"status": "Good"}, status=status.HTTP_200_OK)