From 4b1fd997380bce60ab80e62aeff250595129f593 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 7 Aug 2024 11:33:54 +0800 Subject: [PATCH] bugfix --- appPublic/worker.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/appPublic/worker.py b/appPublic/worker.py index 7c7b183..b0f36d5 100755 --- a/appPublic/worker.py +++ b/appPublic/worker.py @@ -8,9 +8,16 @@ from functools import wraps def awaitify(sync_func): """Wrap a synchronous callable to allow ``await``'ing it""" @wraps(sync_func) - async def async_func(*args, **kwargs): + async def async_func(*args, **kw): loop = asyncio.get_event_loop() - return await loop.run_in_executor(None, sync_func, *args, **kwargs) + return await loop.run_in_executor(None, sync_func, *args, **kw) + return async_func + +def coroutinify(func): + @wraps(sync_func) + async def async_func(*args): + loop = asyncio.get_event_loop() + return await loop.run_in_executor(None, sync_func, *args) return async_func def to_func(func):