python-codecs: add Pillow fallback

This commit is contained in:
Koushik Dutta
2023-03-22 13:08:32 -07:00
parent d19b942d2c
commit 2ecf48bc60
10 changed files with 198 additions and 46 deletions

View 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)