Skip to content

Commit d299052

Browse files
authored
Update awaitme_niyazi_cetinkaya.py
1 parent c69fb42 commit d299052

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Week05/awaitme_niyazi_cetinkaya.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import asyncio
22

3-
def awaitme(func):
4-
async def wrapper(*args, **kwargs):
5-
result = func(*args, **kwargs)
63

7-
# Check if the result is a coroutine and await it if necessary
4+
5+
def awaitme(func):
6+
async def _wrapper(*args,**kwargs):
7+
result = func(*args,**kwargs)
88
if asyncio.iscoroutine(result):
99
return await result
1010
return result
11-
12-
# This ensures the decorated function can be used both synchronously and asynchronously
13-
if asyncio.iscoroutinefunction(func):
14-
return wrapper
15-
else:
16-
# If it's not a coroutine function, return the original function
17-
return func
11+
return _wrapper

0 commit comments

Comments
 (0)