From 544ff6465be0c5e7330fe8f37b5f865fd7cfbfe0 Mon Sep 17 00:00:00 2001 From: yasirarism <55983182+yasirarism@users.noreply.github.com> Date: Tue, 6 Jun 2023 14:57:59 +0000 Subject: [PATCH] Fix --- misskaty/core/decorator/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misskaty/core/decorator/misc.py b/misskaty/core/decorator/misc.py index bea28b1b..a90ae0fb 100644 --- a/misskaty/core/decorator/misc.py +++ b/misskaty/core/decorator/misc.py @@ -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}")