master
yumoqing 2024-02-21 16:51:26 +08:00
parent fb9d2771d1
commit 52ae7b8187
1 changed files with 2 additions and 1 deletions

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