fix(qqbot): stop 100% CPU spin when WebSocket is closed but not None (#31193, #31771)#40574
Conversation
…31193, #31771) _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>
🔎 Lint report:
|
|
Clean and minimal fix for the busy-loop. The guard correctly raises |
…ousResearch#31193, NousResearch#31771) (NousResearch#40574) _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>
…31193, #31771) (#40574) _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>
…ousResearch#31193, NousResearch#31771) (NousResearch#40574) _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>
…ousResearch#31193, NousResearch#31771) (NousResearch#40574) _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>
Summary
Fixes a 100% CPU busy-loop in the QQ bot adapter when the WebSocket is closed but the object isn't None. Closes #31193 and #31771.
_read_events()returned normally in that state (itswhilecondition is false on entry);_listen_looptreats a normal return as a clean read, resets backoff to 0, and immediately retries — pinning a core. Raising on entry routes it through the proper reconnect/backoff path.Changes
gateway/platforms/qqbot/adapter.py: raiseRuntimeErrorwhenself._ws.closedon entry to_read_events.tests/gateway/test_qqbot.py: regression tests for closed-ws and None-ws entry.Validation
TestReadEventsClosedWsGuard2 passed.Salvaged from #40497 (@xushibo) and the byte-identical #40291 (@cnfi); both credited.