HibiKier / nonebot-plugin-zxreport

可爱的小真寻记者为你献上今日报道!
GNU Affero General Public License v3.0
5 stars 1 forks source link

✨ 为网络请求添加重试逻辑 #4

Open BalconyJH opened 13 hours ago

BalconyJH commented 13 hours ago

Summary by Sourcery

新功能:

Original summary in English ## Summary by Sourcery New Features: - Add retry logic to network requests using tenacity library.
sourcery-ai[bot] commented 13 hours ago

审核指南由 Sourcery 提供

此拉取请求为 AsyncHttpx 类中的网络请求添加了重试逻辑。它为 get 方法实现了重试机制,以处理常见的网络相关异常,提高 HTTP 请求的稳健性。

未生成图表,因为更改看起来简单,不需要视觉表示。

文件级更改

更改 详情 文件
为 HTTP GET 请求实现了重试逻辑
  • get 方法添加了重试装饰器
  • 配置了重试次数、等待时间和特定的重试异常
  • 实现了失败请求的错误处理和日志记录
  • 在重试次数耗尽后抛出异常
nonebot_plugin_zxreport/data_source.py

提示和命令 #### 与 Sourcery 互动 - **触发新审核:** 在拉取请求中评论 `@sourcery-ai review`。 - **继续讨论:** 直接回复 Sourcery 的审核评论。 - **从审核评论生成 GitHub 问题:** 通过回复审核评论请求 Sourcery 创建一个问题。 - **生成拉取请求标题:** 在拉取请求标题的任何地方写 `@sourcery-ai` 以随时生成标题。 - **生成拉取请求摘要:** 在拉取请求正文的任何地方写 `@sourcery-ai summary` 以随时生成 PR 摘要。您也可以使用此命令指定摘要应插入的位置。 #### 自定义您的体验 访问您的[仪表板](https://app.sourcery.ai)以: - 启用或禁用审核功能,例如 Sourcery 生成的拉取请求摘要、审核指南等。 - 更改审核语言。 - 添加、删除或编辑自定义审核说明。 - 调整其他审核设置。 #### 获取帮助 - [联系我们的支持团队](mailto:support@sourcery.ai)以获取问题或反馈。 - 访问我们的[文档](https://docs.sourcery.ai)以获取详细指南和信息。 - 通过关注我们在 [X/Twitter](https://x.com/SourceryAI)、[LinkedIn](https://www.linkedin.com/company/sourcery-ai/) 或 [GitHub](https://github.com/sourcery-ai) 上的 Sourcery 团队保持联系。
Original review guide in English ## Reviewer's Guide by Sourcery This pull request adds retry logic to network requests in the `AsyncHttpx` class. It implements a retry mechanism for the `get` method to handle common network-related exceptions, improving the robustness of the HTTP requests. _No diagrams generated as the changes look simple and do not need a visual representation._ ### File-Level Changes | Change | Details | Files | | ------ | ------- | ----- | | Implemented retry logic for HTTP GET requests |
  • Added retry decorator to the `get` method
  • Configured retry attempts, wait time, and specific exceptions to retry on
  • Implemented error handling and logging for failed requests
  • Raised exceptions after retry attempts are exhausted
| `nonebot_plugin_zxreport/data_source.py` | ---
Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).