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

ClientSession.close deprecated when called directly via run_until_complete(2.2.3) #2065

Closed
litwisha opened this issue Jul 6, 2017 · 6 comments
Labels

Comments

@litwisha
Copy link
Contributor

litwisha commented Jul 6, 2017

Long story short

When you close session directly via loop.run_until_complete(session.close()), it is deprecated.
The reason is that _CoroGuard inherits from _BaseCoroMixin that inherits from collections.abc.Coroutine.
https://github.com/aio-libs/aiohttp/blob/v2.2.3/aiohttp/helpers.py#L108
And when calling loop.run_until_complete(session.close()) then __await__ or __iter__ methods are unreachable, send method is called instead. That's why, self._awaited attribute is not changed to True.

Expected behaviour

Direct closing loop.run_until_complete(session.close()) is not deprecated

Actual behaviour

Direct closing loop.run_until_complete(session.close()) is deprecated

Steps to reproduce

import asyncio  
from aiohttp import ClientSession

loop = asyncio.get_event_loop()

session = ClientSession(loop=loop)
loop.run_until_complete(session.close())

Your environment

OS X 10.12.3
python 3.6.0
aiohttp==2.2.3
@asvetlov
Copy link
Member

I pretty sure the issue is fixed by 97db67b and e176536.
https://github.com/aio-libs/aiohttp/blob/master/tests/test_client_session.py#L58-L60 test is finished without any warning

@litwisha
Copy link
Contributor Author

litwisha commented Jul 11, 2017

@asvetlov
no, it is not fixed for py35+.
Here is a negative test for it.
#2077

@litwisha
Copy link
Contributor Author

@asvetlov
any ideas?

@asvetlov
Copy link
Member

Sure :)
This weekend I'll lead a sprint, hope to find a time for making fix.

@asvetlov
Copy link
Member

asvetlov commented Aug 3, 2017

Fixed by @2161
Released in aiohttp 2.2.5

@asvetlov asvetlov closed this as completed Aug 3, 2017
@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants