Skip to content

Commit 9667a8e

Browse files
authored
Merge pull request #674 from katex35/patch-10
Create awaitme_gokay_sahin.py
2 parents 0a226af + ba7ca5e commit 9667a8e

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)