Skip to content

fix: close interrupted asynchronous file uploads - #275

Open
Apeksha9389 wants to merge 1 commit into
AssemblyAI:masterfrom
Apeksha9389:fix/close-interrupted-uploads
Open

Apeksha9389 wants to merge 1 commit into
AssemblyAI:masterfrom
Apeksha9389:fix/close-interrupted-uploads

Conversation

@Apeksha9389

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 745 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.

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.

1 participant