-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Exception handling doesn't close connection #2827
Comments
Looks like you are right. |
Hello. I faced with a similar situation. import asyncio
import aiohttp
async def main():
headers = {"User-Agent": None}
try:
async with aiohttp.ClientSession(headers=headers) as session:
async with session.get("https://google.com", proxy="http://80.151.181.110:80") as resp:
result = await resp.json()
except Exception as e:
print(repr(e))
asyncio.run(main()) This code leads to:
It's happening only if we pass proxy parameter. |
Long story short
With certain malformed urls, the connection is not properly closed. This causes an "Unclosed connection".
Expected behaviour
Connection cleaned up when there is an exception writing headers.
Actual behaviour
Connection not properly cleaned up.
Steps to reproduce
Here are two examples, one mocked and one using a live site. Both should produce an "Unclosed connection" error.
requires pytest and aresponses
Your environment
client
Python 3.6.4
Ubuntu 17.10
virtualenv
aiohttp==3.0.6
possible solution
change aiohttp/client.py lines 328-343 to
The text was updated successfully, but these errors were encountered: