This commit is contained in:
yumoqing 2024-02-21 16:51:26 +08:00
parent fb9d2771d1
commit 52ae7b8187

View File

@ -9,7 +9,8 @@ def awaitify(sync_func):
"""Wrap a synchronous callable to allow ``await``'ing it"""
@wraps(sync_func)
async def async_func(*args, **kwargs):
return sync_func(*args, **kwargs)
loop = asyncio.get_event_loop()
return await loop.run_in_executor(None, sync_func, *args, **kwargs)
return async_func
def to_func(func):