_read_events() returned normally when self._ws was closed-but-non-None (the while-condition is false on entry). _listen_loop treats a normal return as a clean read, resets backoff to 0, and immediately retries — a tight busy-loop pinning CPU. Raising on entry routes it through the reconnect/backoff path instead. Co-authored-by: xushibo <xushibo@users.noreply.github.com> Co-authored-by: cnfi <cnfi@users.noreply.github.com>
This commit is contained in:
@@ -681,6 +681,12 @@ class QQAdapter(BasePlatformAdapter):
|
||||
"""Read WebSocket frames until connection closes."""
|
||||
if not self._ws:
|
||||
raise RuntimeError("WebSocket not connected")
|
||||
if self._ws.closed:
|
||||
# A closed-but-non-None ws makes the while-condition false on entry,
|
||||
# so this would return normally — which _listen_loop treats as a
|
||||
# clean read and immediately retries with backoff reset to 0,
|
||||
# producing a 100% CPU spin. Raise so the reconnect/backoff path runs.
|
||||
raise RuntimeError("WebSocket closed")
|
||||
|
||||
while self._running and self._ws and not self._ws.closed:
|
||||
msg = await self._ws.receive()
|
||||
|
||||
Reference in New Issue
Block a user