Skip to content

handle connection discarding in sending #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion uamqp/async_ops/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions uamqp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down