Skip to content

AsyncConnectionPool leaks connection on CancelledError on 3.8 #149

Closed

Description

@lazitski-aliaksei

From python 3.8 CancelledError a is subclass of BaseException (https://docs.python.org/3.8/library/asyncio-exceptions.html#asyncio.CancelledError)

If coroutine is cancelled after connection was acquired and during request, connection is not removed from the pool:
https://github.com/encode/httpcore/blob/master/httpcore/_async/connection_pool.py#L179

try:
    response = await connection.request(
        method, url, headers=headers, stream=stream, timeout=timeout
    )
except NewConnectionRequired:
    connection = None
except Exception:
    logger.trace("remove from pool connection=%r", connection)
    await self._remove_from_pool(connection)
    raise

Activity

  1. lovelydinosaur commented on Aug 11, 2020

    @lovelydinosaur
    Member

    Related #116

    Thanks yup, looks like we've got a bit of tidying up to do there.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions