diff --git a/pyproject.toml b/pyproject.toml index c69aba078..3ca408222 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -309,6 +309,7 @@ markers = [ [tool.pytest_env] PAPERLESS_DISABLE_DBHANDLER = "true" PAPERLESS_CACHE_BACKEND = "django.core.cache.backends.locmem.LocMemCache" +PAPERLESS_CHANNELS_BACKEND = "channels.layers.InMemoryChannelLayer" [tool.coverage.report] exclude_also = [ diff --git a/src/conftest.py b/src/conftest.py deleted file mode 100644 index 532a767a8..000000000 --- a/src/conftest.py +++ /dev/null @@ -1,11 +0,0 @@ -import pytest -from pytest_django.fixtures import SettingsWrapper - - -@pytest.fixture(autouse=True) -def in_memory_channel_layers(settings: SettingsWrapper) -> None: - settings.CHANNEL_LAYERS = { - "default": { - "BACKEND": "channels.layers.InMemoryChannelLayer", - }, - } diff --git a/src/paperless/settings.py b/src/paperless/settings.py index bee406fa2..f1434605d 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -491,18 +491,24 @@ TEMPLATES = [ }, ] +_CHANNELS_BACKEND = os.environ.get( + "PAPERLESS_CHANNELS_BACKEND", + "channels_redis.pubsub.RedisPubSubChannelLayer", +) CHANNEL_LAYERS = { "default": { - "BACKEND": "channels_redis.pubsub.RedisPubSubChannelLayer", - "CONFIG": { - "hosts": [_CHANNELS_REDIS_URL], - "capacity": 2000, # default 100 - "expiry": 15, # default 60 - "prefix": _REDIS_KEY_PREFIX, - }, + "BACKEND": _CHANNELS_BACKEND, }, } +if _CHANNELS_BACKEND.startswith("channels_redis."): + CHANNEL_LAYERS["default"]["CONFIG"] = { + "hosts": [_CHANNELS_REDIS_URL], + "capacity": 2000, # default 100 + "expiry": 15, # default 60 + "prefix": _REDIS_KEY_PREFIX, + } + ############################################################################### # Email (SMTP) Backend # ###############################################################################