correction using link
This commit is contained in:
parent
4da69740ae
commit
077ac8efa5
1 changed files with 4 additions and 3 deletions
|
@ -13,17 +13,18 @@ def run_in_executor(f):
|
||||||
"""
|
"""
|
||||||
Decorator to make blocking a function call asyncio compatible.
|
Decorator to make blocking a function call asyncio compatible.
|
||||||
https://stackoverflow.com/questions/41063331/how-to-use-asyncio-with-existing-blocking-library/
|
https://stackoverflow.com/questions/41063331/how-to-use-asyncio-with-existing-blocking-library/
|
||||||
|
https://stackoverflow.com/a/53719009
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def inner(*args, **kwargs):
|
async def wrapper(*args, **kwargs):
|
||||||
loop = get_running_loop()
|
loop = get_running_loop()
|
||||||
return loop.run_in_executor(
|
return await loop.run_in_executor(
|
||||||
None,
|
None,
|
||||||
partial(f, *args, **kwargs),
|
partial(f, *args, **kwargs),
|
||||||
)
|
)
|
||||||
|
|
||||||
return inner
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
def get_ttl_hash(seconds: int = 20) -> int:
|
def get_ttl_hash(seconds: int = 20) -> int:
|
||||||
|
|
Loading…
Reference in a new issue