fix(python-sdk): stop audio sender before Parakeet finalization

Merged
1A
1mo ago
+82-0

What changed and why

Cancelling the Python Parakeet transcriber currently sends finalize while its audio sender remains active. Stop and await that sender first, so new PCM cannot cross the finalization boundary and a pending send cannot overlap the finalization frame. This follows the shutdown behavior introduced in #13632 and relates to #13011.

Product invariants affected

none

How it was verified

  • bash sdks/python/test.sh: 49 passed on Windows, using the minimum supported websockets version and injected sockets, without hardware or external STT services.
  • Both added regressions fail on the original implementation: audio is sent after finalize, and the pending sender stops only after finalize.
  • make preflight PYTHON=python: all 14 selected checks passed, including the SDK suite, invariant and failure-class contracts, hygiene, architecture checks, and plan catalog.
  • scripts/pr-preflight --metadata-only --pr-body-file ... and the complete pre-push hook passed for the committed head. The hook required a local Git executable-path workaround for a separately reproduced Windows Bash discovery defect.

Tests

sdks/python/tests/test_parakeet_lifecycle.py now exercises audio arriving during the final transcript drain and an audio send already in progress at cancellation. It verifies sender/finalize ordering, final transcript delivery, preserved cancellation, and socket cleanup.

Failure class (fixes)

Failure-Class: none