diff --git a/uamqp/async_ops/client_async.py b/uamqp/async_ops/client_async.py index fd96b429..3ed45c52 100644 --- a/uamqp/async_ops/client_async.py +++ b/uamqp/async_ops/client_async.py @@ -12,7 +12,7 @@ import logging import uuid -from uamqp import address, authentication, client, constants, errors, compat +from uamqp import address, authentication, client, constants, errors, compat, c_uamqp from uamqp.utils import get_running_loop from uamqp.async_ops.connection_async import ConnectionAsync from uamqp.async_ops.receiver_async import MessageReceiverAsync @@ -568,6 +568,8 @@ async def _client_run_async(self): # pylint: disable=protected-access await self.message_handler.work_async() await asyncio.shield(self._connection.work_async(), loop=self.loop) + if self._connection._state == c_uamqp.ConnectionState.DISCARDING: + raise errors.ConnectionClose(constants.ErrorCodes.InternalServerError) self._waiting_messages = 0 async with self._pending_messages_lock: self._pending_messages = await self._filter_pending_async() diff --git a/uamqp/client.py b/uamqp/client.py index 0fe23bde..7ff0c5f6 100644 --- a/uamqp/client.py +++ b/uamqp/client.py @@ -648,6 +648,8 @@ def _client_run(self): # pylint: disable=protected-access self.message_handler.work() self._connection.work() + if self._connection._state == c_uamqp.ConnectionState.DISCARDING: + raise errors.ConnectionClose(constants.ErrorCodes.InternalServerError) self._waiting_messages = 0 self._pending_messages = self._filter_pending() if self._backoff and not self._waiting_messages: