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

Session not closed in aiohttp.request after exception #3628

Closed
fried-sausage opened this issue Feb 27, 2019 · 2 comments
Closed

Session not closed in aiohttp.request after exception #3628

fried-sausage opened this issue Feb 27, 2019 · 2 comments
Labels

Comments

@fried-sausage
Copy link
Contributor

@fried-sausage fried-sausage commented Feb 27, 2019

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:

  1. server i talk to does not support keep-alive
  2. i programm client that runs on a moving device using wifi network so connection failures are expected
@aio-libs-bot
Copy link
Collaborator

@aio-libs-bot aio-libs-bot commented Feb 27, 2019

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #2920 (AIOHttp failing after some requests), #3523 (aiohttp not forwarding cookies with Session requests), #3031 (aiohttp request exceptions can't be caught sometimes when encountering bad http message), #3296 (aiohttp client session. it doesn't close a connection after keepalive_timeout), and #1403 ([QUESTION] aiohttp.ClientSession.request('GET') issue).

asvetlov pushed a commit that referenced this issue Jul 19, 2019
(cherry picked from commit 20bfadc)

Co-authored-by: Robert Nikolich <rob-joy@yandex.ru>
@asvetlov
Copy link
Member

@asvetlov asvetlov commented Jul 19, 2019

Fixed by #3640

asvetlov added a commit that referenced this issue Jul 20, 2019
(cherry picked from commit 20bfadc)

Co-authored-by: Robert Nikolich <rob-joy@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants