FrameProcessor: system frames are now queued

System frames are now queued. Before, system frames could be generated from any
task and would not guarantee any order which was causing undesired
behavior. Also, it was possible to get into some rare recursion issues because
of the way system frames were executed (they were executed in-place, meaning
calling `push_frame()` would finish after the system frame traversed all the
pipeline). This makes system frames more deterministic.
This commit is contained in:
Aleix Conchillo Flaqué
2025-08-04 17:17:03 -07:00
parent 49a5a1e375
commit a5ea6e1642
3 changed files with 204 additions and 58 deletions

View File

@@ -121,8 +121,8 @@ class Frame:
class SystemFrame(Frame):
"""System frame class for immediate processing.
System frames are frames that are not internally queued by any of the
frame processors and should be processed immediately.
A frame that takes higher priority than other frames. System frames are
handled in order and are not affected by user interruptions.
"""
pass
@@ -132,8 +132,9 @@ class SystemFrame(Frame):
class DataFrame(Frame):
"""Data frame class for processing data in order.
Data frames are frames that will be processed in order and usually
contain data such as LLM context, text, audio or images.
A frame that is processed in order and usually contains data such as LLM
context, text, audio or images. Data frames are cancelled by user
interruptions.
"""
pass
@@ -143,9 +144,11 @@ class DataFrame(Frame):
class ControlFrame(Frame):
"""Control frame class for processing control information in order.
Control frames are frames that, similar to data frames, will be processed
in order and usually contain control information such as frames to update
settings or to end the pipeline.
A frame that, similar to data frames, is processed in order and usually
contains control information such as update settings or to end the pipeline
after everything is flushed. Control frames are cancelled by user
interruptions.
"""
pass
@@ -1206,7 +1209,7 @@ class EndFrame(ControlFrame):
should be shut down. If the transport receives this frame, it will stop
sending frames to its output channel(s) and close all its threads. Note,
that this is a control frame, which means it will be received in the order it
was sent (unlike system frames).
was sent.
"""
pass