-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix: add explicit timeout to OpenAPI tool httpx client #4432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
69d0179
d6546d8
d12bdc2
c02e275
1e9537a
faacc4f
5889a56
67eca33
030f6b9
da76007
e94868a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -560,6 +560,7 @@ def __repr__(self): | |||||
|
|
||||||
| async def _request(**request_params) -> httpx.Response: | ||||||
| async with httpx.AsyncClient( | ||||||
| verify=request_params.pop("verify", True) | ||||||
| verify=request_params.pop("verify", True), | ||||||
| timeout=None, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While setting To make this more robust and prepare for a future change where the timeout is configurable (as mentioned in the PR description), I suggest reading the timeout from Using
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please address this.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the implementation based on the feedback:
|
||||||
| ) as client: | ||||||
| return await client.request(**request_params) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While setting
timeout=Nonerestores the previous behavior ofrequestsand fixes the immediatehttpx.ReadTimeoutissue, it introduces a significant risk. Disabling timeouts can cause requests to hang indefinitely if the remote API is unresponsive, potentially leading to resource exhaustion and service instability.Even though a follow-up is mentioned in the pull request description, I strongly recommend addressing this now by setting a generous default timeout (e.g., 10 minutes) instead of
None. This would provide a crucial safety net. A truly indefinite timeout should be an explicit choice by the user of the tool, not the default behavior.