Skip to content

Comments

fix(core): add default timeout for request session#1358

Merged
SAKURA-CAT merged 2 commits intomainfrom
fix/session-timeout
Dec 5, 2025
Merged

fix(core): add default timeout for request session#1358
SAKURA-CAT merged 2 commits intomainfrom
fix/session-timeout

Conversation

@swpfY
Copy link
Contributor

@swpfY swpfY commented Dec 5, 2025

目前项目存在的一个 Bug 是在 http 请求未响应的情况下,可能是由于网关的原因导致丢包,会导致阻塞上传请求,参考 Requests - Timeout

解决方案是为请求会话设置默认超时时间(60s),避免在请求后未接收到响应的情况下阻塞上传。

为请求会话设置默认超时时间(60s),避免在请求未接收到响应的情况下阻塞上传的情况。
@swpfY swpfY requested a review from SAKURA-CAT December 5, 2025 08:03
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @swpfY, 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!

此拉取请求旨在解决当前项目中 HTTP 请求可能因未响应(例如网关问题或丢包)而导致上传请求阻塞的 Bug。通过为请求会话设置一个 60 秒的默认超时时间,可以有效避免请求无限期等待响应,从而提高系统的稳定性和可靠性。

Highlights

  • 引入默认超时: 为 HTTP 请求会话引入了 60 秒的默认超时时间,以防止请求无限期阻塞。
  • 自定义适配器: 创建了一个 TimeoutHTTPAdapter 类,用于在 requests 会话中统一注入此默认超时,确保所有通过该会话发出的请求都遵循此设置。
  • 会话配置更新: create_session 函数现在使用新的 TimeoutHTTPAdapter 来配置 HTTP 会话,从而自动应用默认超时。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@swpfY swpfY requested review from ShaohonChen and Zeyi-Lin December 5, 2025 08:03
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

本次 PR 旨在为请求会话添加默认超时时间,以避免因网络问题导致请求无限期阻塞,这是一个重要的改进。通过自定义 HTTPAdapter 来实现此功能,整体思路是正确的。

在代码审查中,我发现了一个小问题:当前实现会覆盖用户显式设置的 timeout=None,这会阻止发起永不超时的请求。此外,为了确保新功能的健壮性,建议为其补充相应的单元测试。

具体的修改建议已在代码行评论中提供。

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@SAKURA-CAT SAKURA-CAT added the 🐛 bug Something isn't working label Dec 5, 2025
@SAKURA-CAT SAKURA-CAT merged commit fda4973 into main Dec 5, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the fix/session-timeout branch December 5, 2025 08:26
@swpfY
Copy link
Contributor Author

swpfY commented Dec 5, 2025

@SAKURA-CAT 话说还没加单测来着

@Zeyi-Lin
Copy link
Member

Zeyi-Lin commented Dec 5, 2025

@SAKURA-CAT 话说还没加单测来着

可尝试用Gemini提交单测PR

@SAKURA-CAT
Copy link
Member

@copilot 你解决一下,让gemini审核

@SAKURA-CAT
Copy link
Member

@gemini-code-assist 你解决一下吧,为这个PR补充一些单测,基于主分支新开个分支

@gemini-code-assist
Copy link
Contributor

@SAKURA-CAT 您好!感谢您的提问。我理解您希望我能为这个PR补充一些单元测试并创建新分支。然而,作为AI助手,我无法执行创建分支、修改文件或提交代码等操作。我的职责是提供代码审查反馈和建议,帮助您改进代码。如果您需要我审查您添加的单元测试,请随时在评论中提及我。您可以通过 /gemini review 命令请求我进行代码审查,或者通过 @gemini-code-assist 标签在评论中与我互动。更多可用命令请参考帮助信息:

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@SAKURA-CAT
Copy link
Member

@SAKURA-CAT 您好!感谢您的提问。我理解您希望我能为这个PR补充一些单元测试并创建新分支。然而,作为AI助手,我无法执行创建分支、修改文件或提交代码等操作。我的职责是提供代码审查反馈和建议,帮助您改进代码。如果您需要我审查您添加的单元测试,请随时在评论中提及我。您可以通过 /gemini review 命令请求我进行代码审查,或者通过 @gemini-code-assist 标签在评论中与我互动。更多可用命令请参考帮助信息:

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

那你不太行啊哥们

@gemini-code-assist
Copy link
Contributor

您好 @SAKURA-CAT,我理解您可能对我的能力感到失望。作为AI助手,我确实无法直接修改代码或创建分支。我的主要职责是提供代码审查和建议,帮助您提高代码质量。

关于单元测试,如果您编写了相关的单元测试代码,我可以帮助您审查这些测试的覆盖率、正确性以及是否符合最佳实践。如果您需要关于如何为这个PR编写单元测试的建议,我也可以提供一些思路。

请告诉我您希望我如何协助您。

@SAKURA-CAT
Copy link
Member

@copilot 那还是你解决吧,基于主分支新开个分支为这个PR补充一些单测

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants