How can I fix this error? _GatheringFuture except...
# ask-ai
w
How can I fix this error? _GatheringFuture exception was never retrieved future: <_GatheringFuture finished exception=CancelledError()>
t
The error _GatheringFuture exception was never retrieved future: <_GatheringFuture finished exception=CancelledError()> usually happens when an asyncio task gets cancelled but the exception isn’t handled properly. Don’t worry, I’m here to help you work through it! Here are some steps you can follow: • Ensure Proper Exception Handling: It’s important to always check and handle exceptions from completed tasks using
task.exception()
. • Cancel and Await Pending Tasks: Try using
await utils.aio.cancel_and_wait(task)
to make sure everything shuts down cleanly and exceptions are caught. • Wrap Coroutine Execution: Using
try-except
blocks can really help catch and log exceptions, especially
asyncio.CancelledError
. • Correct Use of `wait_for_playout()`: Avoid calling
SpeechHandle.wait_for_playout()
inside a tool function. Instead, use
RunContext.wait_for_playout()
for better results. • Enable Debug Logging: If you’re still running into trouble, turning on debug mode and gathering detailed logs—including your LiveKit library version, room identifier, and relevant logs—can provide helpful insights. I hope these tips help you get past the issue! Please feel free to reach out if you want me to clarify anything or if you need more assistance. I’m here to support you! Sources: livekit-agents/livekit/agents/voice/speech_handle.py | Still Have Questions