We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c69fb42 commit d299052Copy full SHA for d299052
Week05/awaitme_niyazi_cetinkaya.py
@@ -1,17 +1,11 @@
1
import asyncio
2
3
-def awaitme(func):
4
- async def wrapper(*args, **kwargs):
5
- result = func(*args, **kwargs)
6
7
- # Check if the result is a coroutine and await it if necessary
+
+def awaitme(func):
+ async def _wrapper(*args,**kwargs):
+ result = func(*args,**kwargs)
8
if asyncio.iscoroutine(result):
9
return await result
10
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
+ return _wrapper
0 commit comments