EndFrame: add reason field to indicate why pipeline is being ended
This commit is contained in:
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- `EndFrame` and `EndTaskFrame` have an optional `reason` field to indicate why
|
||||||
|
the pipeline is being ended.
|
||||||
|
|
||||||
- `CancelFrame` and `CancelTaskFrame` have an optional `reason` field to
|
- `CancelFrame` and `CancelTaskFrame` have an optional `reason` field to
|
||||||
indicate why the pipeline is being canceled. This can be also specified when
|
indicate why the pipeline is being canceled. This can be also specified when
|
||||||
you cancel a task with `PipelineTask.cancel(reason="cancellation your
|
you cancel a task with `PipelineTask.cancel(reason="cancellation your
|
||||||
|
|||||||
@@ -1372,9 +1372,15 @@ class EndTaskFrame(TaskFrame):
|
|||||||
This is used to notify the pipeline task that the pipeline should be
|
This is used to notify the pipeline task that the pipeline should be
|
||||||
closed nicely (flushing all the queued frames) by pushing an EndFrame
|
closed nicely (flushing all the queued frames) by pushing an EndFrame
|
||||||
downstream. This frame should be pushed upstream.
|
downstream. This frame should be pushed upstream.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
reason: Optional reason for pushing an end frame.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
reason: Optional[str] = None
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name}(reason: {self.reason})"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -1463,9 +1469,15 @@ class EndFrame(ControlFrame):
|
|||||||
sending frames to its output channel(s) and close all its threads. Note,
|
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
|
that this is a control frame, which means it will be received in the order it
|
||||||
was sent.
|
was sent.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
reason: Optional reason for pushing an end frame.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
reason: Optional[str] = None
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name}(reason: {self.reason})"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ class PipelineTask(BasePipelineTask):
|
|||||||
if isinstance(frame, EndTaskFrame):
|
if isinstance(frame, EndTaskFrame):
|
||||||
# Tell the task we should end nicely.
|
# Tell the task we should end nicely.
|
||||||
logger.debug(f"{self}: received end task frame {frame}")
|
logger.debug(f"{self}: received end task frame {frame}")
|
||||||
await self.queue_frame(EndFrame())
|
await self.queue_frame(EndFrame(reason=frame.reason))
|
||||||
elif isinstance(frame, CancelTaskFrame):
|
elif isinstance(frame, CancelTaskFrame):
|
||||||
# Tell the task we should end right away.
|
# Tell the task we should end right away.
|
||||||
logger.debug(f"{self}: received cancel task frame {frame}")
|
logger.debug(f"{self}: received cancel task frame {frame}")
|
||||||
|
|||||||
Reference in New Issue
Block a user