-
Notifications
You must be signed in to change notification settings - Fork 28
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
Downloads hang indefinitely if connection interrupted from lack of timeout
#1366
Comments
@yarikoptic What should the timeout be set to? |
what would be your judgement? I think |
@yarikoptic That seems high. I was expecting something more like 5 or 10 seconds, but I'm having difficulty finding any resources on optimal timeout values. EDIT: For the record, httpx's default timeout is 5 seconds. |
https://www.python-httpx.org/advanced/#fine-tuning-the-configuration gives an example of using 60 sec for connection time out... Ok, what about mid-ground of 30? ;) here we are to prevent a complete "hang" - waiting for a minute or half of it is IMHO ok compromise. |
So maybe a shorter connection timeout to raise on a nonresponsive server and a longer read timeout to let a connection heal? |
Set 30-second connect & read timeout when downloading files
Thanks y'all ! |
🚀 Issue was released in |
tell me when you're getting sick of me <3
Downloads happen by iterating over some
downloader
object, wrapped in some number ofattempt
s, catchingHTTPErrors
The core of the downloading logic for the default downloader is here, standard
requests
streaming:dandi-cli/dandi/dandiapi.py
Lines 1473 to 1480 in 0971d02
The zarr downloader is I think identical in this block?
dandi-cli/dandi/dandiapi.py
Lines 1903 to 1911 in 0971d02
A timeout is not used in either case, and the
requests
docs warn:and elaborates further on how timeouts are handled after the initial connection here
If the connection is interrupted, the downloader hangs indefinitely even if the connection is re-established.
MWE
0.58.0
To replicate:
dandi download
commandExpected Behavior
Since there is already retry logic around the download command, I think it would be straightforward to
session.get
callrequests.exceptions.Timeout
in existingrequests.exceptions.HTTPError
block, which should already sleep for 5 seconds and retry.Happy to PR this very minimal change :)
The text was updated successfully, but these errors were encountered: