From a1d5719fa79d2a091f21636dc425319db7998952 Mon Sep 17 00:00:00 2001 From: Roma Frolov Date: Fri, 20 Dec 2024 11:29:04 +0300 Subject: [PATCH] feat: broker -> **brokers --- faststream/_internal/application.py | 7 ++++--- faststream/_internal/cli/utils/logs.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/faststream/_internal/application.py b/faststream/_internal/application.py index 5b8c8df14a..185dcf0878 100644 --- a/faststream/_internal/application.py +++ b/faststream/_internal/application.py @@ -121,8 +121,8 @@ def _init_setupable_( # noqa: PLW3201 self._setup() def _setup(self) -> None: - if self.broker: - self.broker._setup(OuterBrokerState(di_state=self._state.di_state)) + for broker in self.brokers: + broker._setup(OuterBrokerState(di_state=self._state.di_state)) async def _start_broker(self) -> None: assert self.broker, "You should setup a broker" @@ -272,7 +272,8 @@ async def _shutdown(self, log_level: int = logging.INFO) -> None: async def stop(self) -> None: """Executes shutdown hooks and stop broker.""" async with self._shutdown_hooks_context(): - await self.broker.close() + for broker in self.brokers: + await broker.close() @asynccontextmanager async def _shutdown_hooks_context(self) -> AsyncIterator[None]: diff --git a/faststream/_internal/cli/utils/logs.py b/faststream/_internal/cli/utils/logs.py index 1c1f98936c..7233378201 100644 --- a/faststream/_internal/cli/utils/logs.py +++ b/faststream/_internal/cli/utils/logs.py @@ -68,4 +68,5 @@ def set_log_level(level: int, app: "Application") -> None: if app.logger and getattr(app.logger, "setLevel", None): app.logger.setLevel(level) # type: ignore[attr-defined] - app.broker._state.get().logger_state.set_level(level) + for broker in app.brokers: + broker._state.get().logger_state.set_level(level)