mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-02 03:48:19 +08:00
add hku_to_async utils method
This commit is contained in:
parent
3ec9a92386
commit
90cc0d93d7
@ -25,6 +25,7 @@ __all__ = [
|
||||
'hku_check_throw',
|
||||
'hku_check_ignore',
|
||||
'hku_catch',
|
||||
'hku_to_async',
|
||||
'hku_trace',
|
||||
'hku_debug',
|
||||
'hku_info',
|
||||
|
@ -10,6 +10,7 @@
|
||||
import sys
|
||||
import traceback
|
||||
import functools
|
||||
import asyncio
|
||||
from .mylog import hku_logger
|
||||
|
||||
|
||||
@ -142,3 +143,11 @@ def hku_catch(ret=None, trace=False, callback=None, retry=1, with_msg=False, re_
|
||||
return wrappedFunc
|
||||
|
||||
return hku_catch_wrap
|
||||
|
||||
|
||||
def hku_to_async(func):
|
||||
@functools.wraps(func)
|
||||
async def async_func(*args, **kwargs):
|
||||
loop = asyncio.get_event_loop()
|
||||
return await loop.run_in_executor(None, func, *args, **kwargs)
|
||||
return async_func
|
||||
|
Loading…
Reference in New Issue
Block a user