agents
agents copied to clipboard
Sporadically seeing "Error in _play_task" from Background Audio player
Hey, we see the following error every now and then:
2025-10-08 15:30:30,524 - ERROR livekit.agents - Error in _play_task
Traceback (most recent call last):
File "/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/livekit/agents/voice/background_audio.py", line 367, in _play_task
await gen.aclose()
RuntimeError: aclose(): asynchronous generator is already running
2025-10-08 15:30:30,526 - ERROR asyncio - Task exception was never retrieved
future: <Task finished name='Task-228' coro=<BackgroundAudioPlayer._play_task() done, defined at /.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py:13> exception=RuntimeError('aclose(): asynchronous generator is already running')>
Traceback (most recent call last):
File "/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/livekit/agents/voice/background_audio.py", line 367, in _play_task
await gen.aclose()
RuntimeError: aclose(): asynchronous generator is already running
We are on the newest version 1.2.14.
Unfortunately, I don't know how to reproduce this. I also found some old issues with the same problem stating it is supposed to be fixed. However, for us this is not the case. I am observing this issue locally as well as in production.