Oliver Ni
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
5 additions and
4 deletions
-
discord/gateway.py
|
|
|
@ -173,8 +173,7 @@ class KeepAliveHandler(threading.Thread): |
|
|
|
|
|
|
|
data = self.get_payload() |
|
|
|
_log.debug(self.msg, self.shard_id, data['d']) |
|
|
|
coro = self.ws.send_heartbeat(data) |
|
|
|
f = asyncio.run_coroutine_threadsafe(coro, loop=self.ws.loop) |
|
|
|
f = asyncio.run_coroutine_threadsafe(self._send_heartbeat(data), loop=self.ws.loop) |
|
|
|
try: |
|
|
|
# block until sending is complete |
|
|
|
total = 0 |
|
|
|
@ -195,8 +194,6 @@ class KeepAliveHandler(threading.Thread): |
|
|
|
|
|
|
|
except Exception: |
|
|
|
self.stop() |
|
|
|
else: |
|
|
|
self._last_send = time.perf_counter() |
|
|
|
|
|
|
|
def get_payload(self) -> Dict[str, Any]: |
|
|
|
return { |
|
|
|
@ -214,6 +211,10 @@ class KeepAliveHandler(threading.Thread): |
|
|
|
self._last_send = time.perf_counter() |
|
|
|
return self.get_payload() |
|
|
|
|
|
|
|
async def _send_heartbeat(self, data: Any) -> None: |
|
|
|
self._last_send = time.perf_counter() |
|
|
|
await self.ws.send_heartbeat(data) |
|
|
|
|
|
|
|
def ack(self) -> None: |
|
|
|
ack_time = time.perf_counter() |
|
|
|
self._last_ack = ack_time |
|
|
|
|