Skip to content

ClientSession.__aexit__ synchronous session close #2063

Closed
@litwisha

Description

Long story short

When using ClientSession as an asynchronous context manager, self.close is not awaited and it throws DeprecationWarning.

Expected behaviour

Returns self.close() in ClientSession.__aexit__

Actual behaviour

Calls self.close() in ClientSession.__aexit__

Steps to reproduce

import asyncio
from aiohttp import ClientSession

loop = asyncio.get_event_loop()


async def coro():
    async with ClientSession(loop=loop):
        pass


loop.run_until_complete(coro())

Your environment

OS X 10.12.3
python 3.6.0
aiohttp==2.2.3

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