Skip to content

Commit ba7ca5e

Browse files
authored
Create awaitme_gokay_sahin.py
1 parent 6a0ee87 commit ba7ca5e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Week05/awaitme_gokay_sahin.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import asyncio
2+
3+
4+
def awaitme(func):
5+
"""
6+
Converts a function into a coroutine.
7+
8+
:return: Coroutine version of the function.
9+
:rtype: Coroutine
10+
"""
11+
async def wrapper(*args, **kwargs):
12+
result = func(*args, **kwargs)
13+
14+
if asyncio.iscoroutine(result):
15+
return await result
16+
else:
17+
return result
18+
19+
return wrapper

0 commit comments

Comments
 (0)