Skip to content

Commit a098dcf

Browse files
committed
fixes appkey
1 parent 15cf699 commit a098dcf

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/service-library/src/servicelib/aiohttp/db_asyncpg_engine.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,22 @@
1717
from ..db_asyncpg_utils import create_async_engine_and_database_ready
1818
from ..logging_utils import log_context
1919

20-
APP_DB_ASYNC_ENGINE_KEY: Final[str] = f"{__name__ }.AsyncEngine"
21-
20+
DB_ASYNC_ENGINE_APPKEY: Final = web.AppKey("DB_ASYNC_ENGINE", AsyncEngine)
2221

2322
_logger = logging.getLogger(__name__)
2423

2524

2625
def _set_async_engine_to_app_state(app: web.Application, engine: AsyncEngine):
27-
if exists := app.get(APP_DB_ASYNC_ENGINE_KEY, None):
28-
msg = f"An instance of {type(exists)} already in app[{APP_DB_ASYNC_ENGINE_KEY}]={exists}"
26+
if exists := app.get(DB_ASYNC_ENGINE_APPKEY, None):
27+
msg = f"An instance of {type(exists)} already in app[{DB_ASYNC_ENGINE_APPKEY}]={exists}"
2928
raise ValueError(msg)
3029

31-
app[APP_DB_ASYNC_ENGINE_KEY] = engine
30+
app[DB_ASYNC_ENGINE_APPKEY] = engine
3231
return get_async_engine(app)
3332

3433

3534
def get_async_engine(app: web.Application) -> AsyncEngine:
36-
engine: AsyncEngine = app[APP_DB_ASYNC_ENGINE_KEY]
35+
engine: AsyncEngine = app[DB_ASYNC_ENGINE_APPKEY]
3736
assert engine # nosec
3837
return engine
3938

0 commit comments

Comments
 (0)