fix: keep weixin_oc polling after getupdates timeout#6902
fix: keep weixin_oc polling after getupdates timeout#6902superjackche wants to merge 2 commits intoAstrBotDevs:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of the Weixin Official Account (OC) adapter by preventing its polling mechanism from halting due to expected Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves the issue where the weixin_oc adapter would crash due to a long-poll timeout. The implementation correctly catches the asyncio.TimeoutError within _poll_inbound_updates, ensuring the adapter remains operational. The addition of regression tests is a valuable contribution, as they thoroughly validate both the fix for timeout scenarios and the preservation of failure behavior for other errors. The changes are well-executed and enhance the adapter's stability.
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #6901 by making the weixin_oc adapter resilient to normal inbound ilink/bot/getupdates long-poll timeouts, so it continues polling instead of exiting the adapter run() loop.
Changes:
- Handle
asyncio.TimeoutErrorinsideWeixinOCAdapter._poll_inbound_updates()and treat it as a non-fatal polling boundary case. - Preserve existing fatal behavior for non-timeout exceptions to avoid masking unrelated inbound failures.
- Add regression tests covering both the timeout-retry path and the non-timeout error path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
astrbot/core/platform/sources/weixin_oc/weixin_oc_adapter.py |
Catch inbound long-poll timeout at the request boundary and return to the main loop without aborting the adapter. |
tests/test_weixin_oc_adapter.py |
Add tests ensuring run() continues after a timeout and stops on a non-timeout inbound exception. |
|
#6915 has a better way to fix this issue, thanks! |
Fixes #6901.
Modifications / 改动点
This PR prevents
weixin_ocfrom exiting when the inboundilink/bot/getupdateslong-poll hits a normalasyncio.TimeoutError.handle the timeout at the
getupdatesrequest boundary insideWeixinOCAdapter._poll_inbound_updates()keep other inbound processing failures on the existing fatal path, so the fix does not mask unrelated errors
add regression tests for both the timeout case and the non-timeout error case
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
Summary by Sourcery
Handle Weixin OC inbound long-poll timeouts without stopping the adapter loop.
Bug Fixes:
Tests: