PipelineTask: set finished_event InterruptionFrame is received
This commit is contained in:
@@ -862,7 +862,7 @@ class InterruptionFrame(SystemFrame):
|
||||
with other frames (so the order is not guaranteed).
|
||||
|
||||
Parameters:
|
||||
wait_event: If not None, the event will be set when the frame
|
||||
finished_event: If not None, the event will be set when the frame
|
||||
reaches the end of the pipeline.
|
||||
"""
|
||||
|
||||
|
||||
@@ -745,7 +745,7 @@ class PipelineTask(BasePipelineTask):
|
||||
# pipeline. This is in case the push task is blocked waiting for a
|
||||
# pipeline-ending frame to finish traversing the pipeline.
|
||||
logger.debug(f"{self}: received interruption task frame {frame}")
|
||||
await self._pipeline.queue_frame(InterruptionFrame())
|
||||
await self._pipeline.queue_frame(InterruptionFrame(finished_event=frame.finished_event))
|
||||
elif isinstance(frame, ErrorFrame):
|
||||
await self._call_event_handler("on_pipeline_error", frame)
|
||||
if frame.fatal:
|
||||
@@ -786,6 +786,10 @@ class PipelineTask(BasePipelineTask):
|
||||
self._pipeline_end_event.set()
|
||||
elif isinstance(frame, HeartbeatFrame):
|
||||
await self._heartbeat_queue.put(frame)
|
||||
elif isinstance(frame, InterruptionFrame) and frame.finished_event:
|
||||
# This should unblock any code waiting for the interruption to
|
||||
# complete.
|
||||
frame.finished_event.set()
|
||||
|
||||
async def _heartbeat_push_handler(self):
|
||||
"""Push heartbeat frames at regular intervals."""
|
||||
|
||||
Reference in New Issue
Block a user