Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Week05/awaitme_berkin_yildirim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import asyncio
from functools import wraps

def awaitme(func):
"""
Calls the given function and awaits if it's an async function,
otherwise calls it normally.
:param func: The function to be called.
"""
@wraps(func)
async def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
if asyncio.iscoroutine(result):
return await result
return result

return wrapper
Loading