-
Notifications
You must be signed in to change notification settings - Fork 50
Close local file handle on session terminate #1155
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
Conversation
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.
Pull request overview
This PR fixes a PermissionError that occurred when saving complete.param on subsequent downloads by ensuring the file handle is properly closed before clearing its reference in the __terminate_session() method.
Key Changes:
- Added proper file handle cleanup in
__terminate_session()to closeself.fhbefore setting it toNone - Added error handling with logging for any exceptions during file close operations
- Used try-except-finally pattern to ensure
self.fhis always set toNoneeven if close fails
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
Test Results 3 files 3 suites 31m 41s ⏱️ Results for commit 28ca460. ♻️ This comment has been updated with latest results. |
Close self.fh in __terminate_session() before clearing it so the OS file descriptor is released. This prevents PermissionError when saving complete.param on subsequent downloads. Log any close errors for diagnostics. Closes #1151
06af460 to
28ca460
Compare
…or installer downloads - Make vehicles/templates backup optional (default off) - Add _compute_sha256() helper and verify downloaded installer when expected SHA256 provided - Use non-vehicles backup by default in update flows Ref: update resilience and security for software update process
- Add get_expected_sha256_from_release() to parse checksum assets or release body - Pass expected SHA256 to download_and_install_on_windows in update manager - Improve installer verification before execution
- Add download_and_install_wheel_asset() helper - Prefer release wheel assets for non-Windows installs and verify SHA256 - Fallback to pip install when no wheel asset is available
- Add retries, exponential backoff and jitter - Support HTTP Range resume when allowed - Preserve progress callback behavior
…b.suppress, and consolidate returns - Split download logic into helper to satisfy PLR0915 - Added `expected_sha256` docstring entry for `download_and_install_on_windows` - Replace try/except pass with `contextlib.suppress(OSError)` - Mark pip install subprocess call with `# noqa: S603` - Consolidate return paths in UpdateManager._perform_download to satisfy PLR0911
…0915) - Extract small helpers: _build_proxies, _existing_size_and_headers, _parse_total_size, _write_response - Keep external API of download_file_from_url unchanged
…y and annotation linters - Move helper functions to module level with proper type annotations - Implement clean retry loop using helpers - Keep external API unchanged
…mpt helper - Extracted `_attempt_download_once` with type annotations - Simplified `download_file_from_url` to reduce cyclomatic complexity - Kept behavior and tests passing
Close self.fh in __terminate_session() before clearing it so the OS file descriptor is released. This prevents PermissionError when saving complete.param on subsequent downloads. Log any close errors for diagnostics.
Closes #1151