This commit is contained in:
yasirarism 2023-06-06 14:57:59 +00:00 committed by GitHub
parent 308467ed1c
commit 544ff6465b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,8 @@
import asyncio
loop = asyncio.get_running_loop()
def asyncify(func):
async def inner(*args, **kwargs):
loop = asyncio.get_running_loop()
func_out = await loop.run_in_executor(None, func, *args, **kwargs)
return func_out
@ -13,6 +12,7 @@ def new_task(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
loop = asyncio.get_running_loop()
return loop.create_task(func(*args, **kwargs))
except Exception as e:
LOGGER.error(f"Failed to create task for {func.__name__} : {e}")