From 2423e7429a8e3cc99b2fc6eb7550538359fcfe9d Mon Sep 17 00:00:00 2001 From: Alexandre Menezes Date: Sat, 23 Mar 2024 18:51:28 -0300 Subject: [PATCH] code refactoring --- rabbit/client.py | 2 +- rabbit/dlx.py | 3 +-- rabbit/subscribe.py | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/rabbit/client.py b/rabbit/client.py index ec8e7e8..0e62975 100644 --- a/rabbit/client.py +++ b/rabbit/client.py @@ -74,7 +74,7 @@ async def persistent_connect(self, **kwargs) -> None: self.transport, self.protocol = await aioamqp.connect(**kwargs) await self.protocol.wait_closed() self.transport.close() - except (OSError, aioamqp.exceptions.AmqpClosedConnection) as err: + except (OSError, AmqpClosedConnection) as err: logger.error( f"ConnectionError: [error='{err}', host='{kwargs.get('host')}', port={kwargs.get('port')}, login='{kwargs.get('login')}']" ) diff --git a/rabbit/dlx.py b/rabbit/dlx.py index 4b6ffb1..b588879 100644 --- a/rabbit/dlx.py +++ b/rabbit/dlx.py @@ -43,8 +43,7 @@ def channel(self, channel: Channel) -> None: async def configure(self) -> None: """Configure DLX channel, queues and exchange.""" try: - await self._configure_queue() - await self._configure_exchange() + await asyncio.gather(self._configure_queue(), self._configure_exchange()) await self._configure_queue_bind() except AttributeNotInitialized: logger.debug("Waiting client initialization...DLX") diff --git a/rabbit/subscribe.py b/rabbit/subscribe.py index 1bc648d..5538a9f 100644 --- a/rabbit/subscribe.py +++ b/rabbit/subscribe.py @@ -90,8 +90,7 @@ async def configure(self, channel: Union[None, Channel] = None) -> None: """Configure subscriber channel, queues and exchange.""" await self.qos(prefetch_count=self.concurrent) with suppress(SynchronizationError): - await self._configure_queue() - await self._dlx.configure() + await asyncio.gather(self._configure_queue(), self._dlx.configure()) await self._configure_exchange() await self._configure_queue_bind()