Skip to content

Commit 3707029

Browse files
paulwetheomonnom
authored andcommitted
add terminate to JobRequest (livekit#2395)
Co-authored-by: Théo Monnom <theo.8bits@gmail.com>
1 parent 8949313 commit 3707029

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

livekit-agents/livekit/agents/job.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def __init__(
494494
self,
495495
*,
496496
job: agent.Job,
497-
on_reject: Callable[[], Coroutine[None, None, None]],
497+
on_reject: Callable[[bool], Coroutine[None, None, None]],
498498
on_accept: Callable[[JobAcceptArguments], Coroutine[None, None, None]],
499499
) -> None:
500500
self._job = job
@@ -523,8 +523,8 @@ def agent_name(self) -> str:
523523
return self._job.agent_name
524524

525525
async def reject(self) -> None:
526-
"""Reject the job request. The job may be assigned to another worker"""
527-
await self._on_reject()
526+
"""Reject the job request. The job will not be assigned to another worker"""
527+
await self._on_reject(True)
528528

529529
async def accept(
530530
self,

livekit-agents/livekit/agents/worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,13 +820,14 @@ async def _answer_availability(self, msg: agent.AvailabilityRequest) -> None:
820820

821821
answered = False
822822

823-
async def _on_reject() -> None:
823+
async def _on_reject(terminate: bool = False) -> None:
824824
nonlocal answered
825825
answered = True
826826

827827
availability_resp = agent.WorkerMessage()
828828
availability_resp.availability.job_id = msg.job.id
829829
availability_resp.availability.available = False
830+
availability_resp.availability.terminate = terminate
830831
await self._queue_msg(availability_resp)
831832

832833
async def _on_accept(args: JobAcceptArguments) -> None:

0 commit comments

Comments
 (0)