Skip to content
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

Bug Fix: Set timeout on requests.get #2064

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Bug Fix: Set timeout on requests.get #2064

merged 1 commit into from
Nov 25, 2024

Conversation

tempusfrangit
Copy link
Member

If requests.get has no timeout it is possible to hang indefinitely on a ill behaved webserver. This timeout is explicitly a connect and read timeout, meaning if no bytes received.

If you don't set a timeout, your request may hang indefinitely.

The timeout parameter is used for connect and read timeouts.  The whole request
may take longer than the timeout; but if the connection takes longer than the
timeout, or if the connection fails to send more data for an interval longer than
the timeout, it will fail.

I chose 5 seconds for the upload_file, which (at least when run on replicate
infrastructure) is always to an endpoint in the same data center.

I chose 10 seconds for downloading URLFile inputs as they may be making a
request over the public internet.

Co-authored-by: Philip Potter <[email protected]>
Copy link
Contributor

@philandstuff philandstuff left a comment

Choose a reason for hiding this comment

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

I amended the commit to have timeouts I thought appropriate, with reasons in the commit message

@philandstuff philandstuff merged commit 3e56e59 into main Nov 25, 2024
19 checks passed
@philandstuff philandstuff deleted the requests-timeout branch November 25, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants