Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions model_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def _run_in_worker():
loop_ready.set()
try:
asyncio.set_event_loop(worker_loop)
return worker_loop.run_until_complete(coro)
tool_task = worker_loop.create_task(coro)
return worker_loop.run_until_complete(tool_task)
finally:
try:
# Cancel anything still pending (e.g. task cancelled
Expand Down Expand Up @@ -167,10 +168,12 @@ def _run_in_worker():
# lifetime — preventing "Event loop is closed" on GC cleanup.
if threading.current_thread() is not threading.main_thread():
worker_loop = _get_worker_loop()
return worker_loop.run_until_complete(coro)
tool_task = worker_loop.create_task(coro)
return worker_loop.run_until_complete(tool_task)

tool_loop = _get_tool_loop()
return tool_loop.run_until_complete(coro)
tool_task = tool_loop.create_task(coro)
return tool_loop.run_until_complete(tool_task)


# =============================================================================
Expand Down