Use local variable instead of instance variable for RTVI prepend decision

Replace _rtvi_external instance variable with a local prepend_rtvi flag
since it is only used during __init__ to decide whether to prepend the
RTVIProcessor to the pipeline.
This commit is contained in:
Rupesh
2026-02-27 14:45:37 -08:00
parent 6f33aff0c6
commit 56f2564ed1

View File

@@ -330,7 +330,7 @@ class PipelineTask(BasePipelineTask):
# RTVI support
self._rtvi = None
self._rtvi_external = False
prepend_rtvi = False
external_rtvi = self._find_processor(pipeline, RTVIProcessor)
external_observer_found = any(isinstance(o, RTVIObserver) for o in observers)
@@ -350,10 +350,10 @@ class PipelineTask(BasePipelineTask):
"They are both added by default, no need to add them yourself."
)
self._rtvi = external_rtvi
self._rtvi_external = True
elif enable_rtvi:
self._rtvi = rtvi_processor or RTVIProcessor()
observers.append(self._rtvi.create_rtvi_observer(params=rtvi_observer_params))
prepend_rtvi = True
if self._rtvi:
# Automatically call RTVIProcessor.set_bot_ready()
@@ -393,10 +393,7 @@ class PipelineTask(BasePipelineTask):
# Only prepend the RTVIProcessor if we created it ourselves. When the
# user already placed it inside their pipeline we must not insert it
# again or it will appear twice in the frame chain.
if self._rtvi and not self._rtvi_external:
processors = [self._rtvi, pipeline]
else:
processors = [pipeline]
processors = [self._rtvi, pipeline] if prepend_rtvi else [pipeline]
self._pipeline = Pipeline(processors, source=source, sink=sink)
# The task observer acts as a proxy to the provided observers. This way,