Implement AsyncHTTPConnection.aclose#96
Conversation
The base class implementation is empty and python will otherwise emit a "ResourceWarning unclosed <socket.socket ...>" for the unclosed sockets.
|
Hiya! So, httpcore is a low-level HTTP client, which means that you're required to ensure you're closing connections, eg. as documented in the quickstart... http_version, status_code, reason_phrase, headers, stream = await http.request(
method=b'GET',
url=(b'https', b'example.org', 443, b'/'),
)
try:
body = b''.join(chunk async for chunk in stream)
finally:
await stream.close()It's really important to use the Higher level clients like Having said that, we should forcibly close outstanding connections, yup, although this PR isn't quite the right approach. (I'm also surprised that it passed the tests - since the sync & async cases aren't in sync here.) |
|
Closing in favour of #98 |
|
I did run into this using Should this have worked without the fix? Is there another bug in httpx? |
|
Ah gotcha. Anyways yup, without #98 we're not properly closing connections when the pool is cleaned up. We'll release a 0.9.1 version shortly. Thanks for having filed this! |
The base class implementation is empty and python will otherwise emit
a "ResourceWarning unclosed <socket.socket ...>" for the unclosed
sockets.