mirror of
https://github.com/koush/scrypted.git
synced 2026-02-09 08:42:19 +00:00
python-codecs: add Pillow fallback
This commit is contained in:
10
plugins/python-codecs/src/thread.py
Normal file
10
plugins/python-codecs/src/thread.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import asyncio
|
||||
from typing import Any
|
||||
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)
|
||||
Reference in New Issue
Block a user