From a8f5516612069a936d94ca3c89967a8a46400856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=96zt=C3=BCrk?= <97892689+burakozturk1@users.noreply.github.com> Date: Mon, 6 Jan 2025 21:50:35 +0300 Subject: [PATCH] Create awaitme_burak_ozturk.py --- Week05/awaitme_burak_ozturk.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Week05/awaitme_burak_ozturk.py diff --git a/Week05/awaitme_burak_ozturk.py b/Week05/awaitme_burak_ozturk.py new file mode 100644 index 00000000..fddfe1db --- /dev/null +++ b/Week05/awaitme_burak_ozturk.py @@ -0,0 +1,9 @@ +import asyncio + +def awaitme(func): + async def wrapped(*a, **kw): + if asyncio.iscoroutinefunction(func): + return await func(*a, **kw) + loop = asyncio.get_event_loop() + return await loop.run_in_executor(None, func, *a) + return wrapped