From 2ce53928d7d12a83e7f07000457d8e4918dd2c9f Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 5 May 2022 11:42:34 -0400 Subject: [PATCH] Fix broken HTTPClient.recreate code to actually clear session --- discord/client.py | 2 +- discord/http.py | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/discord/client.py b/discord/client.py index 6aa28081a..64025e64e 100644 --- a/discord/client.py +++ b/discord/client.py @@ -787,7 +787,7 @@ class Client: self._closed = False self._ready.clear() self._connection.clear() - self.http.recreate() + self.http.clear() async def start(self, token: str, *, reconnect: bool = True) -> None: """|coro| diff --git a/discord/http.py b/discord/http.py index ccf43162a..82160ea99 100644 --- a/discord/http.py +++ b/discord/http.py @@ -382,6 +382,10 @@ class HTTPClient: except AttributeError: pass + def clear(self) -> None: + if self.__session and self.__session.closed: + self.__session = MISSING + async def startup(self) -> None: if self._started: return @@ -695,14 +699,6 @@ class HTTPClient: # State management - def recreate(self) -> None: - if self.__session and self.__session.closed: - self.__session = aiohttp.ClientSession( - connector=self.connector, - loop=self.loop, - trace_configs=None if self.http_trace is None else [self.http_trace], - ) - async def close(self) -> None: if self.__session: await self.__session.close()