Fixed an issue in BaseOutputTransport where the loop could consume all CPU.
This commit is contained in:
@@ -81,6 +81,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an issue in the `BaseOutputTransport`, mainly reproducible with
|
||||
`FastAPIWebsocketOutputTransport` when the audio mixer was enabled, where the
|
||||
loop could consume 100% CPU by continuously returning without delay, preventing
|
||||
other asyncio tasks (such as cancellation or shutdown signals) from being
|
||||
processed.
|
||||
|
||||
- Fixed an issue where `BotStartedSpeakingFrame` and `BotStoppedSpeakingFrame`
|
||||
were not emitted when using `TavusVideoService` or `HeyGenVideoService`.
|
||||
|
||||
|
||||
@@ -658,6 +658,11 @@ class BaseOutputTransport(FrameProcessor):
|
||||
num_channels=self._params.audio_out_channels,
|
||||
)
|
||||
yield frame
|
||||
# Allow other asyncio tasks to execute by adding a small sleep
|
||||
# Without this sleep, in task cancellation scenarios, this loop would
|
||||
# continuously return without any delay, leading to 100% CPU utilization
|
||||
# and preventing cancel/stop signals from being processed properly
|
||||
await asyncio.sleep(0)
|
||||
|
||||
if self._mixer:
|
||||
return with_mixer(BOT_VAD_STOP_SECS)
|
||||
|
||||
Reference in New Issue
Block a user