You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'This event loop is already running' error when using LiteLLM inside another event loop #1647
LiteLLMInferenceEngine, as it is implemented on unitxt, creates an event loop. FastAPI/Jupyter Notebooks also create one. asyncio doesn't allow nested loop, so we need to rely on nest_asyncio to handle them.
We should catch this error and add an error message with instructions and suggested fix
@martinscooper I opened #1982 for this. Calling sync inference inside a running loop now raises a UnitxtError that suggests asyncio.to_thread(engine.infer, dataset) or nest_asyncio.apply(). It also fixes LiteLLMInferenceEngine failing after asyncio.run(), from worker threads, and on Python 3.14. cc @elronbandel@yoavkatz
Activity
github-actions commentedon Apr 10, 2025
This issue is stale because it has been open for 30 days with no activity.
github-actions commentedon May 16, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.
wak327 commentedon Oct 3, 2026
@martinscooper I opened #1982 for this. Calling sync inference inside a running loop now raises a
UnitxtErrorthat suggestsasyncio.to_thread(engine.infer, dataset)ornest_asyncio.apply(). It also fixesLiteLLMInferenceEnginefailing afterasyncio.run(), from worker threads, and on Python 3.14. cc @elronbandel @yoavkatz