Repository navigation
Conversation
The heartbeat watchdog compares the time of the last PONG against the wall clock, so a host that steps forward counts a missed heartbeat that was answered, and after max_heartbeat_failures the connection is dropped. monotonic() only moves forward; the field starts at monotonic() so the first interval is measured from connect instead of from the epoch.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
KOOK 适配器的心跳看门狗用墙钟判断超时(修复前是
time.time()):宿主校时(NTP 或人工改时间)前跳时,这段时间差会被算成「很久没收到 PONG」→ 失败计数自增,累加到
max_heartbeat_failures就判定连接已死、断开重连;后跳则相反,真的丢 PONG 也发现不了。PONG 到达与这次检查之间隔着await self._send_ping()和await asyncio.sleep(...),正是「两次读数之间跨 IO」的典型形状。改动
last_heartbeat_time的写入与比较都改用time.monotonic();字段初始化也从0改成time.monotonic(),这样第一次检查是从连接建立开始计时,而不是从纪元开始(原写法第一次检查必然超时)。验证
ruff check与ruff format --check通过(仅该文件)