[python] 增加时间窗口保护,避免与热加载注册冲突 #364
Merged
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.
🔗 相关问题 / Related Issue
Issue 链接 / Issue Link:
📋 变更类型 / Type of Change
📝 变更目的 / Purpose of the Change
当前在启动框架之后,python 插件(可以正常上传并部署)上传部署失败,未出现任何错误日志信息
问题原因在于,心跳这边为了避免所有的插件异常下线之后部署失败,添加了在_try_heart_beat_once调用时,重新注册所有插件的逻辑,但是这样会导致热加载的插件因为_try_heart_beat_once的频繁调用导致注册失败,进而导致插件部署失败。
因此添加了
1、心跳重连成功后,需要重新注册所有服务,确保服务不丢失,但为了避免覆盖热加载刚注册的服务,增加时间窗口保护(3倍心跳间隔)
2、距离上次注册时间超过保护窗口,可以注册(用于兜底,防止服务丢失)
📋 主要变更 / Brief Changelog
重连场景:心跳重连成功后立即注册,解决服务丢失问题
热加载保护:通过时间窗口避免覆盖热加载刚注册的服务
平衡机制:既保证服务不丢失,又避免频繁注册影响热加载
心跳间隔默认 3000ms(3秒)
保护窗口 = 3 × 3秒 = 9秒
热加载扫描周期通常为 3 秒,9 秒的保护窗口足够覆盖热加载注册
🧪 验证变更 / Verifying this Change
测试步骤 / Test Steps
测试覆盖 / Test Coverage
📸 截图 / Screenshots
✅ 贡献者检查清单 / Contributor Checklist
请确保你的 Pull Request 符合以下要求 / Please ensure your Pull Request meets the following requirements:
基本要求 / Basic Requirements:
代码质量 / Code Quality:
测试要求 / Testing Requirements:
mvn -B clean package -Dmaven.test.skip=true/ Basic checks passmvn clean install/ Unit tests pass文档和兼容性 / Documentation and Compatibility:
📋 附加信息 / Additional Notes
审查者注意事项 / Reviewer Notes: