Skip to content

Session not closed in aiohttp.request after exception #3628

Closed
@fried-sausage

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:

  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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions