Mercurial > code > home > repos > light9
view src/light9/blender/asyncio_thread.py @ 2450:a4052905ca7d default tip
notes about how rdfdb syncs, or should sync
author | drewp@bigasterisk.com |
---|---|
date | Mon, 03 Jun 2024 23:01:54 -0700 |
parents | b8a408caf115 |
children |
line wrap: on
line source
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