Files
scrypted/plugins/python-codecs/src/thread.py
2023-03-27 11:14:53 -07:00

10 lines
351 B
Python

import asyncio
import concurrent.futures
# vips is already multithreaded, but needs to be kicked off the python asyncio thread.
toThreadExecutor = concurrent.futures.ThreadPoolExecutor(max_workers=2, thread_name_prefix="image")
async def to_thread(f):
loop = asyncio.get_running_loop()
return await loop.run_in_executor(toThreadExecutor, f)