Skip to content

Commit 958fa49

Browse files
author
Andrei Neagu
committed
refactor
1 parent 0e12373 commit 958fa49

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/service-library/src/servicelib/fastapi/postgres_lifespan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections.abc import AsyncIterator
44
from enum import Enum
55

6+
from fastapi import FastAPI
67
from fastapi_lifespan_manager import State
78
from servicelib.logging_utils import log_catch, log_context
89
from settings_library.postgres import PostgresSettings
@@ -27,7 +28,7 @@ def create_postgres_database_input_state(settings: PostgresSettings) -> State:
2728
return {PostgresLifespanState.POSTGRES_SETTINGS: settings}
2829

2930

30-
async def postgres_database_lifespan(_, state: State) -> AsyncIterator[State]:
31+
async def postgres_database_lifespan(_: FastAPI, state: State) -> AsyncIterator[State]:
3132

3233
with log_context(_logger, logging.INFO, f"{__name__}"):
3334

services/catalog/src/simcore_service_catalog/repository/events.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
_logger = logging.getLogger(__name__)
1414

1515

16-
repository_lifespan_manager = LifespanManager()
17-
repository_lifespan_manager.add(postgres_database_lifespan)
18-
19-
20-
@repository_lifespan_manager.add
2116
async def _database_lifespan(app: FastAPI, state: State) -> AsyncIterator[State]:
2217
app.state.engine = state[PostgresLifespanState.POSTGRES_ASYNC_ENGINE]
2318

@@ -26,3 +21,8 @@ async def _database_lifespan(app: FastAPI, state: State) -> AsyncIterator[State]
2621
app.state.default_product_name = await repo.get_default_product_name()
2722

2823
yield {}
24+
25+
26+
repository_lifespan_manager = LifespanManager()
27+
repository_lifespan_manager.add(postgres_database_lifespan)
28+
repository_lifespan_manager.add(_database_lifespan)

0 commit comments

Comments
 (0)