Fix: UnboundLocalError and improve download resilience with automatic retries#4
Open
AnderCMD wants to merge 5 commits into
Open
Fix: UnboundLocalError and improve download resilience with automatic retries#4AnderCMD wants to merge 5 commits into
AnderCMD wants to merge 5 commits into
Conversation
…thentication credentials
There was a problem hiding this comment.
Pull request overview
Implements a reusable requests.Session with retry behavior for Google Backup API calls, and updates download flow/error handling to better tolerate per-file failures.
Changes:
- Add
requests.Sessionconfigured withHTTPAdapter+urllib3.Retryand routeWaBackup.get()through it. - Change request exception handling to raise on failure (instead of swallowing) and return the
Responseon success. - Make
fetch()returnNoneon failure and updatefetch_all()to skip checksum/size accounting for failed downloads.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Author
|
@copilot apply changes based on the comments in this thread |
…ings for WhatsApp backup extraction
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.
This PR addresses a crash during the synchronization process and improves the overall reliability of the extractor when facing network instability.
Changes:
Fixed UnboundLocalError in WaBackup.get:
Previously, the get method would catch RequestException but attempt to return the response variable even if it was never assigned. The method now correctly handles exceptions by raising them after logging, ensuring the flow is properly managed.
Implemented Automatic Retries:
Integrated requests.Session with a urllib3.util.Retry strategy.
The client now automatically retries failed requests up to 5 times with an exponential backoff. This prevents crashes caused by transient network issues (like DNS resolution failures or temporary connection drops).
Improved Download Resilience:
Refactored fetch_all to handle individual file failures gracefully. If a file fails to download after all retries, the process now logs the error and continues with the remaining files instead of halting the entire synchronization.
Added connection pooling via requests.Session for better performance during large backups (10,000+ files).
Enhanced User Feedback:
Added more descriptive error messages when a request or a specific file fetch fails.
Technical Details:
Retries: Configured for common status codes (429, 500, 502, 503, 504).
Exception Handling: Wrapped file fetching in a try-except block within the thread pool worker to ensure thread safety and continuity.