Make EndFrame and StopFrame uninterruptible to prevent pipeline freeze

This commit is contained in:
Luke Payyapilli
2026-01-23 10:11:22 -05:00
parent 4c10ddb7bb
commit 8d3e10f054
2 changed files with 111 additions and 2 deletions

View File

@@ -1751,7 +1751,7 @@ class BotInterruptionFrame(InterruptionTaskFrame):
@dataclass
class EndFrame(ControlFrame):
class EndFrame(ControlFrame, UninterruptibleFrame):
"""Frame indicating pipeline has ended and should shut down.
Indicates that a pipeline has ended and frame processors and pipelines
@@ -1760,6 +1760,10 @@ class EndFrame(ControlFrame):
that this is a control frame, which means it will be received in the order it
was sent.
This frame is marked as UninterruptibleFrame to ensure it is not lost when
an InterruptionFrame is processed. Terminal frames must survive interruption
to guarantee proper pipeline shutdown.
Parameters:
reason: Optional reason for pushing an end frame.
"""
@@ -1771,12 +1775,16 @@ class EndFrame(ControlFrame):
@dataclass
class StopFrame(ControlFrame):
class StopFrame(ControlFrame, UninterruptibleFrame):
"""Frame indicating pipeline should stop but keep processors running.
Indicates that a pipeline should be stopped but that the pipeline
processors should be kept in a running state. This is normally queued from
the pipeline task.
This frame is marked as UninterruptibleFrame to ensure it is not lost when
an InterruptionFrame is processed. Terminal frames must survive interruption
to guarantee proper pipeline control.
"""
pass