correction using link

This commit is contained in:
Jörn-Michael Miehe 2022-09-05 13:02:15 +00:00
parent 4da69740ae
commit 077ac8efa5

View file

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