Mercurial > code > home > repos > light9
comparison 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 |
comparison
equal
deleted
inserted
replaced
2452:f21b61884b0f | 2453:b23afde50bc2 |
---|---|
1 import asyncio | |
2 from threading import Thread | |
3 from typing import Coroutine | |
4 | |
5 | |
6 def startLoopInThread(task: Coroutine) -> asyncio.AbstractEventLoop: | |
7 | |
8 def start_background_loop(loop: asyncio.AbstractEventLoop) -> None: | |
9 asyncio.set_event_loop(loop) | |
10 loop.run_forever() | |
11 | |
12 loop = asyncio.new_event_loop() | |
13 t = Thread(target=start_background_loop, args=(loop,), daemon=True) | |
14 t.start() | |
15 asyncio.run_coroutine_threadsafe(task, loop) | |
16 return loop |