Skip to content

Conversation

@Showmick119
Copy link

Fixes #2708

Changes

  • Changed except Exception blocks to finally blocks in both sync and async versions of upload_file_chunked
  • Ensures file handles are always closed, even on successful uploads

Bug

Previously, file handles were only closed on exceptions, causing resource leaks on successful uploads.

Changed exception-only close() to finally block to ensure file handles
are always closed, preventing resource leaks on successful uploads.
@Showmick119 Showmick119 requested a review from a team as a code owner October 28, 2025 01:34
@karpetrosyan
Copy link
Collaborator

karpetrosyan commented Oct 28, 2025

Doesn't using with buf: instead of try/finally look better?

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.

File handle resource leak in upload_file_chunked method

2 participants