|
4 | 4 | from pathlib import Path |
5 | 5 |
|
6 | 6 | import environ |
| 7 | +from celery.schedules import crontab |
7 | 8 |
|
8 | 9 | BASE_DIR = Path(__file__).resolve(strict=True).parent.parent.parent |
9 | 10 | # pi23_gswdt/ |
|
81 | 82 | "rest_framework.authtoken", |
82 | 83 | "corsheaders", |
83 | 84 | "drf_spectacular", |
| 85 | + "django_celery_results", |
84 | 86 | ] |
85 | 87 |
|
86 | 88 | LOCAL_APPS = [ |
|
268 | 270 | # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url |
269 | 271 | CELERY_BROKER_URL = env("CELERY_BROKER_URL") |
270 | 272 | # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend |
271 | | -CELERY_RESULT_BACKEND = CELERY_BROKER_URL |
| 273 | +CELERY_RESULT_BACKEND = "django-db" |
272 | 274 | # https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended |
273 | 275 | CELERY_RESULT_EXTENDED = True |
274 | 276 | # https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry |
|
337 | 339 | } |
338 | 340 | # Your stuff... |
339 | 341 | # ------------------------------------------------------------------------------ |
| 342 | +REDIS_URL = env("CELERY_BROKER_URL", default="redis://redis:6379/0") |
| 343 | + |
| 344 | +CACHES = { |
| 345 | + "default": { |
| 346 | + "BACKEND": "django_redis.cache.RedisCache", |
| 347 | + "LOCATION": REDIS_URL, |
| 348 | + "OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient", "PICKLE_VERSION": 5}, |
| 349 | + "IGNORE_EXCEPTIONS": True, |
| 350 | + "TIMEOUT": 3600, |
| 351 | + }, |
| 352 | +} |
| 353 | + |
| 354 | +CELERY_CACHE_BACKEND = "default" |
| 355 | +CELERY_BEAT_SCHEDULE = { |
| 356 | + "task__test_celery": { |
| 357 | + "task": "task__test_celery", |
| 358 | + "args": (1, 2, 3), |
| 359 | + "kwargs": {"a": 1, "b": 2, "c": 3}, |
| 360 | + "schedule": crontab( |
| 361 | + **{"minute": "*/3", "hour": "*", "day_of_week": "*", "day_of_month": "*", "month_of_year": "*"} |
| 362 | + ), |
| 363 | + }, |
| 364 | +} |
0 commit comments