Skip to content

AsyncConnectionPool hangs future connections sometimes when a connection get canceled. #830

Description

@fusiyuan2010

In async def handle_async_request(self, request: Request) -> Response: there are such lines:

        async with self._pool_lock:
            self._requests.append(status)
            await self._close_expired_connections()
            await self._attempt_to_acquire_connection(status)

There is a probability that the coroutine got canceled after self._requests.append(status) but before await self._attempt_to_acquire_connection. Since these few lines are not protected against canceling nor having cleaning up on exception, it may leave a status stayed in _requests forever, blocking all future connection = await status.wait_for_connection(timeout=timeout) which is a few lines after.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions