From 589aa77ba7d5e009fdebbd5b2d5b59cf60307d02 Mon Sep 17 00:00:00 2001 From: Rahul Saini Date: Thu, 10 Nov 2022 15:05:10 -0800 Subject: [PATCH] uwsgi snuba init --- snuba/cli/__init__.py | 2 +- snuba/core/initialize.py | 4 ++-- snuba/web/wsgi.py | 2 ++ test_initialization/test_initialize.py | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/snuba/cli/__init__.py b/snuba/cli/__init__.py index 6a4fd8af62..96b3a3f5db 100644 --- a/snuba/cli/__init__.py +++ b/snuba/cli/__init__.py @@ -56,7 +56,7 @@ def get_command(self, ctx: Any, name: str) -> click.Command: # That way if any command code references any snuba construct that needs # to be initialized (e.g. a factory) at import time, it is already initialized # into the runtime - initialize.initialize() + initialize.initialize_snuba() fn = os.path.join(plugin_folder, actual_command_name + ".py") with open(fn) as f: code = compile(f.read(), fn, "exec") diff --git a/snuba/core/initialize.py b/snuba/core/initialize.py index 414d140f8e..530463032e 100644 --- a/snuba/core/initialize.py +++ b/snuba/core/initialize.py @@ -29,8 +29,8 @@ def _load_entities() -> None: initialize_entity_factory() -def initialize() -> None: - logger.info("Initializing snuba") +def initialize_snuba() -> None: + logger.info("Initializing Snuba") # The order of the functions matters The reference direction is # diff --git a/snuba/web/wsgi.py b/snuba/web/wsgi.py index 6dc653797b..d0d624fb62 100644 --- a/snuba/web/wsgi.py +++ b/snuba/web/wsgi.py @@ -1,6 +1,8 @@ +from snuba.core.initialize import initialize_snuba from snuba.environment import setup_logging, setup_sentry setup_logging() setup_sentry() +initialize_snuba() from snuba.web.views import application # noqa diff --git a/test_initialization/test_initialize.py b/test_initialization/test_initialize.py index 132b6adfb1..8ac465eae9 100644 --- a/test_initialization/test_initialize.py +++ b/test_initialization/test_initialize.py @@ -1,6 +1,6 @@ from unittest import mock -from snuba.core.initialize import initialize +from snuba.core.initialize import initialize_snuba class TestInitialization: @@ -17,7 +17,7 @@ def test_init( for factory in (_DS_FACTORY, _ENT_FACTORY, _STORAGE_FACTORY): assert factory is None - initialize() + initialize_snuba() from snuba.datasets.entities.factory import get_all_entity_names from snuba.datasets.factory import get_enabled_dataset_names from snuba.datasets.storages.factory import get_all_storage_keys