From 5903c517f76c68c351a8452d79ad51034ca324b1 Mon Sep 17 00:00:00 2001 From: Sylvain <35365065+sanderegg@users.noreply.github.com> Date: Fri, 7 Jan 2022 11:23:40 +0100 Subject: [PATCH] sleep before restarting consumer (#2722) --- .../src/simcore_service_webserver/computation_subscribe.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/web/server/src/simcore_service_webserver/computation_subscribe.py b/services/web/server/src/simcore_service_webserver/computation_subscribe.py index 013da0ac382..9c06d2b1cac 100644 --- a/services/web/server/src/simcore_service_webserver/computation_subscribe.py +++ b/services/web/server/src/simcore_service_webserver/computation_subscribe.py @@ -114,6 +114,7 @@ async def events_message_parser(app: web.Application, data: bytes) -> None: APP_RABBITMQ_POOL_KEY = f"{__name__}.pool" +_RABBITMQ_INTERVAL_BEFORE_RESTARTING_CONSUMER_S = 2 async def setup_rabbitmq_consumer(app: web.Application) -> AsyncIterator[None]: @@ -196,6 +197,10 @@ async def exchange_consumer( "restarting..." if consumer_running else "stopping", exc_info=True, ) + if consumer_running: + await asyncio.sleep(_RABBITMQ_INTERVAL_BEFORE_RESTARTING_CONSUMER_S) + + # TODO consumer_tasks = [] for exchange_name, message_parser, consumer_kwargs in [