We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fdb4de0 commit c69fb42Copy full SHA for c69fb42
Week05/awaitme_niyazi_cetinkaya.py
@@ -0,0 +1,17 @@
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
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
0 commit comments