Session not closed in aiohttp.request after exception #3628
Closed
Description
Long story short
subj
First I get ClientConnectorError (connection-related errors are expected in my application), after that i see Unclosed client session warning.
Expected behaviour
ClientSession, created inside aiohttp.request, is closed after programm leaves async with block.
Actual behaviour
ClientSession is not closed.
Steps to reproduce
import asyncio
import aiohttp
async def main():
async with aiohttp.request("GET", "http://127.0.0.1:8080") as resp:
pass
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(main())
finally:
loop.close()
Your environment
aiohttp 3.5.4
python 3.5
debian stretch
Why use aiohttp.request at all, opening new connection for every request is bad
I need to open new connection anyway:
- server i talk to does not support keep-alive
- i programm client that runs on a moving device using wifi network so connection failures are expected