diff --git a/Week05/awaitme_gokay_sahin.py b/Week05/awaitme_gokay_sahin.py new file mode 100644 index 00000000..4c6babc2 --- /dev/null +++ b/Week05/awaitme_gokay_sahin.py @@ -0,0 +1,19 @@ +import asyncio + + +def awaitme(func): + """ + Converts a function into a coroutine. + + :return: Coroutine version of the function. + :rtype: Coroutine + """ + async def wrapper(*args, **kwargs): + result = func(*args, **kwargs) + + if asyncio.iscoroutine(result): + return await result + else: + return result + + return wrapper