Skip to content

Commit e84703f

Browse files
authored
Merge pull request #564 from egeenc0/patch-15
Create awaitme_ege_enc.py
2 parents ccfcf07 + fbb1483 commit e84703f

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)