Using client sessions without a context manager #3119
Labels
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
Hacktoberfest
We think it's good for https://hacktoberfest.digitalocean.com/
outdated
It would be useful to be able to use ClientSession without a context manager.
Looking at the code:
ClientSession.__aenter__
does not do anything (See https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client.py#L827 );ClientSession.__aexit__
only doesawait self.close()
(See https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client.py#L830).So the following currently works:
However the documentation doesn't specify whether we can rely on this behaviour. I can see three options:
ClientSession.start()
even if it currently does nothing for future-proofing);__aenter__
and__aexit__
directly, I understand it's an accepted thing to do).I'm happy to help and do a PR for whichever solution you prefer.
The text was updated successfully, but these errors were encountered: