Skip to content

Commit 9619ddb

Browse files
authored
fix: Change event sets, fix proper close() WS handling (#1061)
1 parent 1cf1b61 commit 9619ddb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

interactions/api/gateway/client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ async def _reconnect(self, to_resume: bool, code: Optional[int] = 1012) -> None:
701701
Restarts the client's connection and heartbeat with the Gateway.
702702
"""
703703

704-
self._ready.clear()
704+
self.ready.clear()
705705

706706
async with self.reconnect_lock:
707707
self.__closed.clear()
@@ -831,9 +831,11 @@ async def _send_packet(self, data: Dict[str, Any]) -> None:
831831
# This is because the ratelimiter limits already accounts for this.
832832
await self._ratelimiter.block()
833833

834-
self._last_send = perf_counter()
835-
log.debug(packet)
836-
await self._client.send_str(packet)
834+
if self._client is not None: # this mitigates against another edge case.
835+
self._last_send = perf_counter()
836+
log.debug(packet)
837+
838+
await self._client.send_str(packet)
837839

838840
async def __identify(
839841
self, shard: Optional[List[Tuple[int]]] = None, presence: Optional[ClientPresence] = None
@@ -919,4 +921,4 @@ async def close(self) -> None:
919921
"""
920922
if self._client:
921923
await self._client.close()
922-
self._closed = True
924+
self.__closed.set()

0 commit comments

Comments
 (0)