fix: keep weixin_oc polling after inbound timeouts#6915
fix: keep weixin_oc polling after inbound timeouts#6915Soulter merged 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 addresses an issue where the 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 modifies the weixin_oc_adapter to gracefully handle asyncio.TimeoutError during inbound long-polling, logging the timeout and ensuring the polling loop continues. A new test case has been added to verify this behavior. The review suggests an improvement in the new test to use patch.object for mocking, which would enhance robustness and clarity.
tests/test_weixin_oc_adapter.py
Outdated
| adapter._poll_inbound_updates = fake_poll_inbound_updates # type: ignore[method-assign] | ||
|
|
||
| with patch( | ||
| "astrbot.core.platform.sources.weixin_oc.weixin_oc_adapter.logger" | ||
| ) as mock_logger: | ||
| await adapter.run() |
There was a problem hiding this comment.
To improve test robustness and clarity, consider using patch.object as a context manager for monkey-patching. This practice ensures that the original method is restored automatically after the test, even in case of errors, and it eliminates the need for a type: ignore comment.
with patch.object(adapter, '_poll_inbound_updates', new=fake_poll_inbound_updates):
with patch('astrbot.core.platform.sources.weixin_oc.weixin_oc_adapter.logger') as mock_logger:
await adapter.run()
Summary
Closes #6901
Testing
Summary by Sourcery
Handle Weixin OC inbound long-poll timeouts as recoverable errors so the adapter continues polling instead of exiting.
Bug Fixes:
Tests: