Skip to content

Commit fbb1483

Browse files
authored
Create awaitme_ege_enc.py
1 parent acd18e1 commit fbb1483

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Week05/awaitme_ege_enc.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import asyncio
2+
3+
def awaitme(func):
4+
"""
5+
This function waits if it receives an async function, otherwise it just calls the function.
6+
:param func: The function to be called.
7+
"""
8+
async def await_case(*args, **kwargs):
9+
result = func(*args, **kwargs)
10+
11+
if asyncio.iscoroutine(result):
12+
return await result
13+
else:
14+
return result
15+
16+
return await_case

0 commit comments

Comments
 (0)