Skip to content

Commit daef293

Browse files
authored
handle connection discarding in sending (#225)
1 parent 825dfd8 commit daef293

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

uamqp/async_ops/client_async.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import logging
1313
import uuid
1414

15-
from uamqp import address, authentication, client, constants, errors, compat
15+
from uamqp import address, authentication, client, constants, errors, compat, c_uamqp
1616
from uamqp.utils import get_running_loop
1717
from uamqp.async_ops.connection_async import ConnectionAsync
1818
from uamqp.async_ops.receiver_async import MessageReceiverAsync
@@ -568,6 +568,8 @@ async def _client_run_async(self):
568568
# pylint: disable=protected-access
569569
await self.message_handler.work_async()
570570
await asyncio.shield(self._connection.work_async(), loop=self.loop)
571+
if self._connection._state == c_uamqp.ConnectionState.DISCARDING:
572+
raise errors.ConnectionClose(constants.ErrorCodes.InternalServerError)
571573
self._waiting_messages = 0
572574
async with self._pending_messages_lock:
573575
self._pending_messages = await self._filter_pending_async()

uamqp/client.py

+2
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,8 @@ def _client_run(self):
648648
# pylint: disable=protected-access
649649
self.message_handler.work()
650650
self._connection.work()
651+
if self._connection._state == c_uamqp.ConnectionState.DISCARDING:
652+
raise errors.ConnectionClose(constants.ErrorCodes.InternalServerError)
651653
self._waiting_messages = 0
652654
self._pending_messages = self._filter_pending()
653655
if self._backoff and not self._waiting_messages:

0 commit comments

Comments
 (0)