Add timeout/retry config to download() to prevent silent hangs - #27
Open
Yuxiang-Ren-HUB wants to merge 1 commit into
Open
Add timeout/retry config to download() to prevent silent hangs#27Yuxiang-Ren-HUB wants to merge 1 commit into
Yuxiang-Ren-HUB wants to merge 1 commit into
Conversation
boto3.client('s3') in _download() had no Config, so a stalled
connection on an unreliable network could block the whole
ThreadPoolExecutor indefinitely with no error or output. Adds a
sane default Config (30s connect / 180s read timeout, 5 retries)
and an optional boto3_config kwarg on download() for callers who
want to tune it further.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Calling
NexradAwsInterface().download()on a batch of files can hang indefinitely with no exception and no output. This happened to me downloading KOKX scans for 2023-03-14 — the process just sat there until I killed it manually.Root cause
_download()creates the S3 client with noConfig:With no
connect_timeout/read_timeout/retries, a single stalled connection inside theThreadPoolExecutor(max_workers=threads)pool used bydownload()can blockas_completed()forever, since nothing bounds how long one worker is allowed to take.Fix
DEFAULT_DOWNLOAD_CONFIG(30s connect timeout, 180s read timeout, 5 retries with standard backoff) used by default.boto3_configkwarg ondownload()(threaded through to_download()) so callers on unreliable networks can tune it further if needed.Testing
Ran
tests/test_nexradAwsInterface.py::test_download_singleagainst the real bucket — passes, file downloads correctly with the new config applied.