diff --git a/weaver/utils.py b/weaver/utils.py index e9b7aec0b..55308b71a 100644 --- a/weaver/utils.py +++ b/weaver/utils.py @@ -49,6 +49,7 @@ from pyramid.settings import asbool, aslist from pyramid.threadlocal import get_current_registry from pyramid_beaker import set_cache_regions_from_settings +from pyramid_celery import celery_app as app from requests import HTTPError as RequestsHTTPError, Response from requests.structures import CaseInsensitiveDict from requests_file import FileAdapter @@ -468,6 +469,8 @@ def get_registry(container=None, nothrow=False): return container.registry if isinstance(container, Registry): return container + if container is None and sys.argv[0].rsplit("/", 1)[-1] == "celery": + return app.conf.get("PYRAMID_REGISTRY", {}) if isinstance(container, WerkzeugRequest) or container is None: return get_current_registry() if nothrow: