Close the cached HTTP session explicitly. UI helper flows may run on short-lived event loops created per request. Closing the cached session at the end of those flows prevents aiohttp from reporting unclosed sessions/connectors when the loop exits.
(self, *, loop: asyncio.AbstractEventLoop | None = None)
| 195 | self._http_session_loop = None |
| 196 | |
| 197 | async def close_http_session(self, *, loop: asyncio.AbstractEventLoop | None = None) -> None: |
| 198 | """Close the cached HTTP session explicitly. |
| 199 | |
| 200 | UI helper flows may run on short-lived event loops created per request. |
| 201 | Closing the cached session at the end of those flows prevents aiohttp |
| 202 | from reporting unclosed sessions/connectors when the loop exits. |
| 203 | """ |
| 204 | |
| 205 | async with self._get_lock(): |
| 206 | if loop is not None and self._http_session_loop is not loop: |
| 207 | return |
| 208 | await self._close_http_session_locked() |
| 209 | |
| 210 | async def _restart_for_auth_refresh_locked(self) -> None: |
| 211 | await self._close_http_session_locked() |