Browse Source

Refactor HTTP client lifecycle

pull/10109/head
dolfies 2 years ago
parent
commit
915b9b8caa
  1. 16
      discord/http.py

16
discord/http.py

@ -616,6 +616,11 @@ class HTTPClient:
if self._started:
return
self._global_over = asyncio.Event()
self._global_over.set()
if self.connector is MISSING or self.connector.closed:
self.connector = aiohttp.TCPConnector(limit=0)
self.__session = session = await _gen_session(
aiohttp.ClientSession(
connector=self.connector, trace_configs=None if self.http_trace is None else [self.http_trace]
@ -693,6 +698,9 @@ class HTTPClient:
captcha_handler = self.captcha_handler
route_key = route.key
if not self._started:
await self.startup()
bucket_hash = None
try:
bucket_hash = self._bucket_hashes[route_key]
@ -1052,14 +1060,6 @@ class HTTPClient:
async def static_login(self, token: str) -> user.User:
old_token, self.token = self.token, token
if self.connector is MISSING:
self.connector = aiohttp.TCPConnector(limit=0)
self._global_over = asyncio.Event()
self._global_over.set()
await self.startup()
try:
data = await self.get_me()
except HTTPException as exc:

Loading…
Cancel
Save