You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ClientSession.ws_connect() method is synchronous and returns a
_RequestContextManager which takes a coroutine as parameter (here,
ClientSession._ws_connect()).
This context manager is in charge of closing the connection in its __aexit__()
method, so it has to be used with "async with".
However, this context manager can also be awaited as it has an __await__()
method. In this case, it will await the _ws_connect() coroutine. This is what is
done in the current code, but the connection will not be released.
Remove the "await" to return the context manager, so that the user can use it
with "async with", which will properly release resources.
This is the documented way of using ws_connect():
https://docs.aiohttp.org/en/stable/client_quickstart.html#websockets
Signed-off-by: Olivier Matz <[email protected]>
0 commit comments