From 64d2efd314169f374bc9c7aefe4a1d47ba9097f2 Mon Sep 17 00:00:00 2001 From: Luciano Gervasoni Date: Sun, 6 Apr 2025 21:03:57 +0200 Subject: [PATCH] Reverting to django tasks scheduler version --- app_urls/core/settings.py | 38 ++++++++++++++++++++++++++++++++++---- app_urls/requirements.txt | 4 ++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app_urls/core/settings.py b/app_urls/core/settings.py index 8270ff1..f7c0fc3 100644 --- a/app_urls/core/settings.py +++ b/app_urls/core/settings.py @@ -11,7 +11,6 @@ https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path -from scheduler.types import SchedulerConfiguration import os # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -111,7 +110,35 @@ CACHES = { } } +''' +from scheduler.types import SchedulerConfiguration, QueueConfiguration, Broker +from typing import Dict + # https://django-tasks-scheduler.readthedocs.io/en/latest/configuration/ +SCHEDULER_CONFIG = SchedulerConfiguration( + DEFAULT_JOB_TIMEOUT = os.environ.get("JOB_DEFAULT_TIMEOUT", 60*30), # 30 minutes + BROKER=Broker.REDIS, +) + +SCHEDULER_QUEUES: Dict[str, QueueConfiguration] = { + 'default': QueueConfiguration( + HOST = os.environ.get("REDIS_HOST", "localhost"), + PORT = os.environ.get("REDIS_PORT", 6379), + DB = os.environ.get("REDIS_DB", 0), + ), + 'high': QueueConfiguration( + HOST = os.environ.get("REDIS_HOST", "localhost"), + PORT = os.environ.get("REDIS_PORT", 6379), + DB = os.environ.get("REDIS_DB", 0), + ), + 'low': QueueConfiguration( + HOST = os.environ.get("REDIS_HOST", "localhost"), + PORT = os.environ.get("REDIS_PORT", 6379), + DB = os.environ.get("REDIS_DB", 0), + ), +} +''' + SCHEDULER_QUEUES = { 'default': { 'HOST': os.environ.get("REDIS_HOST", "localhost"), @@ -129,10 +156,13 @@ SCHEDULER_QUEUES = { 'DB': os.environ.get("REDIS_DB", 0), } } +SCHEDULER_CONFIG = { + 'DEFAULT_TIMEOUT': os.environ.get("JOB_DEFAULT_TIMEOUT", 60*30), # 30 minutes + 'DEFAULT_RESULT_TTL': 60*60*12, # 12 hours + 'EXECUTIONS_IN_PAGE': 20, + 'SCHEDULER_INTERVAL': 10, # 10 seconds +} -SCHEDULER_CONFIG = SchedulerConfiguration( - DEFAULT_JOB_TIMEOUT = os.environ.get("JOB_DEFAULT_TIMEOUT", 60*30), # 30 minutes -) # Password validation diff --git a/app_urls/requirements.txt b/app_urls/requirements.txt index 04c2c38..01b23ff 100644 --- a/app_urls/requirements.txt +++ b/app_urls/requirements.txt @@ -1,7 +1,7 @@ django==5.1 -psycopg[binary] +django-tasks-scheduler==3.0.1 django-redis -django-tasks-scheduler +psycopg[binary] gunicorn whitenoise feedparser