WatchdogQueue: make WatchdogQueueCancelSentinel public

This commit is contained in:
Aleix Conchillo Flaqué
2025-08-12 11:34:05 -07:00
parent 929fd98958
commit f3efc9da00

View File

@@ -20,7 +20,14 @@ from pipecat.utils.asyncio.task_manager import BaseTaskManager
@dataclass @dataclass
class _WatchdogQueueCancelSentinel: class WatchdogQueueCancelSentinel:
"""Sentinel object used in queues to force cancellation.
An instance of this class is typically inserted into a `WatchdogQueue` to
act as a marker for asyncio task cancellation.
"""
pass pass
@@ -61,7 +68,7 @@ class WatchdogQueue(asyncio.Queue):
else: else:
get_result = await super().get() get_result = await super().get()
if isinstance(get_result, _WatchdogQueueCancelSentinel): if isinstance(get_result, WatchdogQueueCancelSentinel):
logger.trace( logger.trace(
"Received WatchdogQueueCancelFrame, throwing CancelledError to force cancelling" "Received WatchdogQueueCancelFrame, throwing CancelledError to force cancelling"
) )
@@ -90,7 +97,7 @@ class WatchdogQueue(asyncio.Queue):
forces the task to raise CancelledError when consumed, ensuring proper forces the task to raise CancelledError when consumed, ensuring proper
task termination. task termination.
""" """
super().put_nowait(_WatchdogQueueCancelSentinel()) super().put_nowait(WatchdogQueueCancelSentinel())
async def _watchdog_get(self): async def _watchdog_get(self):
"""Get item from queue while periodically resetting watchdog timer.""" """Get item from queue while periodically resetting watchdog timer."""