Mercurial > code > home > repos > light9
diff blender/asyncio_thread.py @ 2453:b23afde50bc2
blender addons get thier own pdm setup for now. fix time_from_graph startup race
author | drewp@bigasterisk.com |
---|---|
date | Sun, 18 May 2025 20:08:35 -0700 |
parents | src/light9/blender/asyncio_thread.py@b8a408caf115 |
children | 405abed9a45c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/blender/asyncio_thread.py Sun May 18 20:08:35 2025 -0700 @@ -0,0 +1,16 @@ +import asyncio +from threading import Thread +from typing import Coroutine + + +def startLoopInThread(task: Coroutine) -> asyncio.AbstractEventLoop: + + def start_background_loop(loop: asyncio.AbstractEventLoop) -> None: + asyncio.set_event_loop(loop) + loop.run_forever() + + loop = asyncio.new_event_loop() + t = Thread(target=start_background_loop, args=(loop,), daemon=True) + t.start() + asyncio.run_coroutine_threadsafe(task, loop) + return loop