Skip to content

fix: close interrupted asynchronous file uploads - #275

Open
Apeksha9389 wants to merge 3 commits into
AssemblyAI:masterfrom
Apeksha9389:fix/close-interrupted-uploads
Open

Apeksha9389 wants to merge 3 commits into
AssemblyAI:masterfrom
Apeksha9389:fix/close-interrupted-uploads

Conversation

@Apeksha9389

@Apeksha9389 Apeksha9389 commented Oct 20, 2026 •

Copy link
Copy Markdown

AsyncTranscriber.upload_file(path) leaves its opened file suspended in the upload generator when HTTP transmission fails, is cancelled, or returns before consuming the whole body. The file remains open after the method exits, until asynchronous generator finalization eventually runs. Repeated interrupted uploads can retain file descriptors and prevent immediate file cleanup on platforms that lock open files.

Close the SDK-created upload generator in finally, triggering the existing path iterator's file cleanup before returning or propagating the original error. Caller-supplied file objects remain caller-owned. Generator annotations now expose aclose() to type checkers. There is no public API change.

Validation: all 924 unit tests pass on Python 3.12, and Ruff check/format pass on the changed files. The three new path regressions (write error, cancellation, early HTTP response) all fail on unchanged master; the caller-owned-file control passes there. Tests use a local custom httpx transport that consumes one chunk before stopping, with real temporary files. No provider requests or live transcription were run.

Includes the requested patch version bump to 1.8.3, above current master's 1.8.2. Updated validation includes the current master changes; package version and version-increment checks pass.

@ccampbell-aai

Copy link
Copy Markdown
Contributor

Hi @Apeksha9389, thanks for your contribution! Please include a version bump and we can get this in.

@Apeksha9389

Copy link
Copy Markdown
Author

Added the version bump to 1.8.3 after syncing with current master (1.8.2). All 924 unit tests pass locally on Python 3.12, along with Ruff and the version-increment check.

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.

2 participants