-
Notifications
You must be signed in to change notification settings - Fork 3
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
Enhance error handling in download_file function to include HTTPError and RequestException #150
Conversation
… and RequestException
📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request focus on enhancing the error handling capabilities of the Changes
Assessment against linked issues
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
util/lib.py (2)
602-612
: Refactor retry logic to reduce code duplicationThe exception handling for
ChunkedEncodingError
andRequestException
contains similar retry logic.Consider combining the retry logic:
- except ChunkedEncodingError as e: - logging.warning( - "ChunkedEncodingError encountered: %s. Retrying %s/%s...", - e, attempt + 1, retries - ) - except RequestException as e: + except (ChunkedEncodingError, RequestException) as e: logging.warning( - "Failed to download %s: %s (%s). Retrying %s/%s...", - url, e, type(e).__name__, attempt + 1, retries + "Download error: %s (%s). Retrying %s/%s...", + e, type(e).__name__, attempt + 1, retries )
Line range hint
583-583
: Consider making timeout configurableThe timeout value is hardcoded to 1000000 seconds (≈11.6 days), which seems excessive.
Consider making it configurable:
-def download_file(url, dest_path, retries=3): +def download_file(url, dest_path, retries=3, timeout=3600): attempt = 0 while attempt < retries: try: - response = requests.get(url, stream=True, timeout=1000000) + response = requests.get(url, stream=True, timeout=timeout)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
util/lib.py
(2 hunks)
🔇 Additional comments (1)
util/lib.py (1)
14-15
: LGTM: Import changes align with enhanced error handling requirements
The addition of HTTPError
and RequestException
imports supports the improved error handling strategy.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM;
I am assuming you know what you are doing removing
except Exception as e:
Which could bring the whole house down crashing if you are not super sure!
I changed to a more specific exception because it'll only have 'request exceptions' in this function. |
Fix #149
Summary by CodeRabbit
New Features
Bug Fixes