Skip to content

Serialize Python runner synthesis to prevent cross-request PCM bleed#12

Open
phyceClaw wants to merge 1 commit into
phyce:python-integrationfrom
phyceClaw:fix/python-runner-concurrency
Open

Serialize Python runner synthesis to prevent cross-request PCM bleed#12
phyceClaw wants to merge 1 commit into
phyce:python-integrationfrom
phyceClaw:fix/python-runner-concurrency

Conversation

@phyceClaw

Copy link
Copy Markdown

Summary

routeStdout routes all runner stdout to whichever sink is currently attached, but nothing serialized concurrent streamSynth calls. Since dispatchFutures produces futures concurrently, two Synthesize calls on the same Python engine could overlap and the second attachSink would reset routedBytes and steal the first request PCM.

Synthesis is now serialized per runner via a dedicated mutex held across a single request (independent of the engine mutex / restart logic; ctx cancellation still releases it).

Testing

go test -race ./app/tts/engine/python/... passes (includes the cross-request-bleed protocol tests).

🤖 Generated with Claude Code

routeStdout routes all runner stdout to the currently-attached sink,
but concurrent streamSynth calls (dispatchFutures produces futures
concurrently) could overlap: the second attachSink reset routedBytes
and stole the first request PCM. Serialize synthesis per runner with
a dedicated mutex held across a single request.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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