Browse Source

Merge 66f2f41ad1 into 2fbed93624

pull/10448/merge
Oliver Ni 1 month ago
committed by GitHub
parent
commit
d6bd9d33eb
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      discord/gateway.py

9
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

Loading…
Cancel
Save