Skip to content
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

Async client does not close underlying stream thus leaving connection active which leads to hitting pool limit #1315

Closed
2 tasks done
daa opened this issue Sep 23, 2020 · 0 comments · Fixed by #1316
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@daa
Copy link
Contributor

daa commented Sep 23, 2020

Checklist

  • The bug is reproducible against the latest release and/or master.
  • There are no similar issues or pull requests to fix it yet.

Describe the bug

AsyncClient doesn't close httpcore's stream after performing request, the bug shows itself in locking on connection pool's semaphore.

To reproduce

$ python3.8 -m asyncio
>>> import asyncio
>>> import httpx
>>> c = httpx.AsyncClient()
>>> await c.get('http://httpbin.org/')
<Response [200 OK]>
>>> c._transport._connections
{(b'http', b'httpbin.org', 80): {<AsyncHTTPConnection http_version=HTTP/1.1 state=2>}}
>>> await c.get('http://httpbin.org/')
<Response [200 OK]>
>>> c._transport._connections
{(b'http', b'httpbin.org', 80): {<AsyncHTTPConnection http_version=HTTP/1.1 state=2>, <AsyncHTTPConnection http_version=HTTP/1.1 state=2>}}

Expected behavior

There should be one connection in pool in IDLE state.

Actual behavior

There are 2 connection in ACTIVE state in pool after performing and finishing request.

Debugging material

Environment

  • OS: Linux
  • Python version: 3.8.5
  • HTTPX version: 0.15.0
  • Async environment: asyncio/trio
  • HTTP proxy: no
  • Custom certificates: no

Additional context

Bug is most obvious in long-running process making regular request to one endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants