HTTPClient context manager gets stuck on exit
vzakaznikov opened this issue · 1 comments
vzakaznikov commented
Describe the bug
The HTTPClient
context manager gets stuck on exit if the response content is not read or the response connection is not released manually.
To Reproduce
async with aiosonic.HTTPClient() as client:
resp = await client.get('https://github.com')
Expected behavior
Response connection should be released automatically.
Workaround
async with aiosonic.HTTPClient() as client:
resp = await client.get('https://github.com')
# either read the response until the end
print(await resp.content())
# or manually release the response connection
await resp.connection.release()
geraldog commented
I confirm the issue exists. However the test_get_chunked_response_and_not_read_it() passes because there is an explicit delete on the HttpResponse object.
Together with #456 you could call an explicit delete on the response within the HTTPClient managed context if you know you're not going to read the response, and there's a guarantee that it will release the connection thus unblocking Connector cleanup.
Like this:
async def main():
async with aiosonic.HTTPClient() as client:
resp = await client.get('https://github.com')
del resp