From f4133e0236c89cf4902b91bd2dcadb1514a4c31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Thu, 30 Nov 2023 22:37:10 -0300 Subject: [PATCH 1/2] celerywyrm: allow broker and result backend from the environment This allows to easily configure an in-memory transport for tests. --- celerywyrm/settings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/celerywyrm/settings.py b/celerywyrm/settings.py index 20f194a12..3ca9b2748 100644 --- a/celerywyrm/settings.py +++ b/celerywyrm/settings.py @@ -15,8 +15,12 @@ REDIS_BROKER_URL = env( f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/{REDIS_BROKER_DB_INDEX}", ) -CELERY_BROKER_URL = REDIS_BROKER_URL.replace("unix:", "redis+socket:") -CELERY_RESULT_BACKEND = REDIS_BROKER_URL.replace("unix:", "redis+socket:") +CELERY_BROKER_URL = env( + "CELERY_BROKER_URL", REDIS_BROKER_URL.replace("unix:", "redis+socket:") +) +CELERY_RESULT_BACKEND = env( + "CELERY_RESULT_BACKEND", REDIS_BROKER_URL.replace("unix:", "redis+socket:") +) CELERY_DEFAULT_QUEUE = "low_priority" CELERY_CREATE_MISSING_QUEUES = True From 3d28019146e58a9be3502bd22d1525ba9ecf1750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Thu, 30 Nov 2023 22:43:35 -0300 Subject: [PATCH 2/2] Use in-memory backends for Celery in tests and workflows At the moment, this doesn't have much of an effect since most task calls are mock'd out. --- pytest.ini | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pytest.ini b/pytest.ini index b963fb316..74970e877 100644 --- a/pytest.ini +++ b/pytest.ini @@ -15,11 +15,8 @@ env = ALLOWED_HOSTS = your.domain.here BOOKWYRM_DATABASE_BACKEND = postgres MEDIA_ROOT = images/ - CELERY_BROKER = - REDIS_BROKER_PORT = 6379 - REDIS_BROKER_PASSWORD = beep - REDIS_ACTIVITY_PORT = 6379 - REDIS_ACTIVITY_PASSWORD = beep + CELERY_BROKER_URL = memory:// + CELERY_RESULT_BACKEND = cache+memory:// USE_DUMMY_CACHE = true FLOWER_PORT = 8888 EMAIL_HOST = smtp.mailgun.org