Merge pull request #4434 from pipecat-ai/filipi/fix_interruption_regression
Fix interruption blocked by slow non-uninterruptible frame in queue
This commit is contained in:
1
changelog/4434.fixed.md
Normal file
1
changelog/4434.fixed.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Fixed interruptions being delayed when a slow non-uninterruptible frame was processing and an uninterruptible frame was waiting in the queue. The bot would stall until the slow frame finished instead of cancelling it immediately on interruption.
|
||||||
@@ -877,14 +877,19 @@ class FrameProcessor(BaseObject):
|
|||||||
current_is_uninterruptible = isinstance(
|
current_is_uninterruptible = isinstance(
|
||||||
self.__process_current_frame, UninterruptibleFrame
|
self.__process_current_frame, UninterruptibleFrame
|
||||||
)
|
)
|
||||||
if current_is_uninterruptible or self.__process_queue.has_uninterruptible:
|
if current_is_uninterruptible:
|
||||||
# We don't want to cancel an UninterruptibleFrame (either the
|
# The frame currently being processed is uninterruptible, so we
|
||||||
# one currently being processed or one waiting in the queue),
|
# must not cancel it. Just flush non-uninterruptible frames from
|
||||||
# so we simply cleanup the queue keeping only
|
# the queue; any uninterruptible ones will be kept and processed
|
||||||
# UninterruptibleFrames.
|
# after the current frame finishes.
|
||||||
self.__reset_process_queue()
|
self.__reset_process_queue()
|
||||||
else:
|
else:
|
||||||
# Cancel and re-create the process task.
|
# Cancel and re-create the process task. Previously this branch
|
||||||
|
# was skipped when the queue contained an uninterruptible frame,
|
||||||
|
# which caused slow non-uninterruptible frames to block
|
||||||
|
# interruptions. Uninterruptible queued frames are safe here
|
||||||
|
# because __create_process_task calls __reset_process_queue
|
||||||
|
# internally, which always preserves them.
|
||||||
await self.__cancel_process_task()
|
await self.__cancel_process_task()
|
||||||
self.__create_process_task()
|
self.__create_process_task()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user