Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions astrbot/core/platform/sources/weixin_oc/weixin_oc_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,13 @@ async def run(self) -> None:
"weixin_oc(%s): inbound long-poll timeout",
self.meta().id,
)
except Exception as e:
logger.error(
"weixin_oc(%s): poll inbound updates failed, will retry after 5 seconds: %s",
self.meta().id,
e,
)
Comment on lines +906 to +910
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using logger.exception here will provide a full traceback in the logs, which is very helpful for debugging the root cause of the polling failure. It's generally a good practice to log the full exception context for unexpected errors, even if they are being retried. logger.exception automatically includes exception information and should be used within an except block.

                    logger.exception(
                        "weixin_oc(%s): poll inbound updates failed, will retry after 5 seconds",
                        self.meta().id,
                    )

await asyncio.sleep(5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The retry delay 5 is a magic number. Consider defining it as a constant at the class or module level (e.g., POLL_RETRY_DELAY = 5) to improve readability and maintainability. This makes it easier to find and change the value in the future.

except asyncio.CancelledError:
raise
except Exception as e:
Expand Down
Loading