这是indexloc提供的服务,不要输入任何密码
Skip to content

add RunContext.wait_for_playout and guard against deadlocks #2966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2025

Conversation

theomonnom
Copy link
Member

No description provided.

@theomonnom theomonnom requested a review from a team July 22, 2025 13:33
@theomonnom theomonnom merged commit a3d6430 into main Jul 22, 2025
22 of 24 checks passed
@theomonnom theomonnom deleted the theo/fix-deadlock branch July 22, 2025 14:00
@shivamkataria2000
Copy link

Hi, I think I am facing the same issue with wait for playout after upgrading to 1.2.0.
@theomonnom What can I do to fix this until these changes are released?

`from livekit.agents import function_tool, RunContext
from livekit.agents import get_job_context
from livekit import api
import logging

logger = logging.getLogger(name)

@function_tool(
name="end_call",
description="End the current call gracefully.",
)

async def end_call(ctx: RunContext, reason: str = "completed") -> str:
"""
End the current call gracefully.

Args:
    reason: Reason for ending the call (completed, busy, error, etc.)

Returns:
    Confirmation message
"""
logger.info(f"Ending call with reason: {reason}")

current_speech = ctx.session.current_speech
if current_speech:
    logger.info(f"Waiting for current speech to playout {current_speech.chat_items} {current_speech.id}")
    await current_speech.wait_for_playout()
    logger.info("Current speech playout completed")

job_ctx = get_job_context()

try:
    await job_ctx.api.room.delete_room(api.DeleteRoomRequest(room=job_ctx.room.name))
except Exception as e:
    logger.error(f"Error ending call: {e}")
    await job_ctx.room.disconnect()

return f"Call ended successfully with reason: {reason}"

`

@theomonnom
Copy link
Member Author

Hey @shivamkataria2000, I'm going to release a new version tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants