Skip to content

fix: enforce connection and read timeouts on external audio downloads#36

Open
iyedmdimegh wants to merge 1 commit intoruxailab:mainfrom
iyedmdimegh:fix/audio-download-timeout
Open

fix: enforce connection and read timeouts on external audio downloads#36
iyedmdimegh wants to merge 1 commit intoruxailab:mainfrom
iyedmdimegh:fix/audio-download-timeout

Conversation

@iyedmdimegh
Copy link
Copy Markdown

No description provided.

@iyedmdimegh
Copy link
Copy Markdown
Author

While going through the codebase as part of my GSoC 2026 application,
I noticed that external audio downloads in AudioDataLayer had no timeout
set on the requests.get() call so, as a result, on a slow or unresponsive server this
can block the Flask worker thread indefinitely, or freeze the API.

The fix uses a (10, 300) timeout tuple: 10s on the connection so
unreachable servers fail fast, and 300s on the read to give large
audio/video files enough time to actually finish downloading without
triggering a false timeout.

I also added a dedicated Timeout exception handler that raises a clear RuntimeError including the URL.

On the testing side, I added test_fetch_audio_from_url_timeout to verify both that the timeout tuple is passed to requests.get and that the expected RuntimeError message is raised on timeout.

Ran the full test suite: 93 passed, 4 warnings.

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