Skip to content

Add timeout/retry config to download() to prevent silent hangs - #27

Open
Yuxiang-Ren-HUB wants to merge 1 commit into
aarande:masterfrom
Yuxiang-Ren-HUB:add-download-timeout-config
Open

Add timeout/retry config to download() to prevent silent hangs#27
Yuxiang-Ren-HUB wants to merge 1 commit into
aarande:masterfrom
Yuxiang-Ren-HUB:add-download-timeout-config

Conversation

@Yuxiang-Ren-HUB

Copy link
Copy Markdown

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 no Config:

s3 = boto3.client('s3')
s3.download_file('unidata-nexrad-level2', awsnexradfile.key, filepath)

With no connect_timeout/read_timeout/retries, a single stalled connection inside the ThreadPoolExecutor(max_workers=threads) pool used by download() can block as_completed() forever, since nothing bounds how long one worker is allowed to take.

Fix

  • Added DEFAULT_DOWNLOAD_CONFIG (30s connect timeout, 180s read timeout, 5 retries with standard backoff) used by default.
  • Added an optional boto3_config kwarg on download() (threaded through to _download()) so callers on unreliable networks can tune it further if needed.

Testing

Ran tests/test_nexradAwsInterface.py::test_download_single against the real bucket — passes, file downloads correctly with the new config applied.

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.
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.

1 participant