Skip to content

Commit abbeaa4

Browse files
fix: lifespan
1 parent ca423cf commit abbeaa4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

services/notifications/src/simcore_service_notifications/core/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def create_app() -> FastAPI:
4646
description=SUMMARY,
4747
version=f"{VERSION}",
4848
openapi_url=f"/api/{API_VTAG}/openapi.json",
49-
lifespan=events.create_app_lifespan(),
49+
lifespan=events.create_app_lifespan(settings),
5050
**get_common_oas_options(is_devel_mode=settings.SC_BOOT_MODE.is_devel_mode()),
5151
)
5252
override_fastapi_openapi_method(app)

services/notifications/src/simcore_service_notifications/core/events.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def _settings_lifespan(app: FastAPI) -> AsyncIterator[State]:
3636
}
3737

3838

39-
def create_app_lifespan():
39+
def create_app_lifespan(settings: ApplicationSettings) -> LifespanManager:
4040
# WARNING: order matters
4141
app_lifespan = LifespanManager()
4242
app_lifespan.add(_settings_lifespan)
@@ -45,14 +45,15 @@ def create_app_lifespan():
4545
app_lifespan.add(postgres_database_lifespan)
4646
app_lifespan.add(postgres_lifespan)
4747

48-
# - rabbitmq
49-
app_lifespan.add(rabbitmq_lifespan)
48+
if settings.NOTIFICATIONS_CELERY and not settings.NOTIFICATIONS_WORKER_MODE:
49+
# - rabbitmq
50+
app_lifespan.add(rabbitmq_lifespan)
5051

51-
# - celery
52-
app_lifespan.add(celery_lifespan)
52+
# - celery
53+
app_lifespan.add(celery_lifespan)
5354

54-
# - rpc api routes
55-
app_lifespan.add(rpc_api_routes_lifespan)
55+
# - rpc api routes
56+
app_lifespan.add(rpc_api_routes_lifespan)
5657

5758
# - prometheus instrumentation
5859
app_lifespan.add(prometheus_instrumentation_lifespan)

0 commit comments

Comments
 (0)