As stated in this question, we can turn a function into a coroutine using the asyncio.coroutine decorator to turn a function into a coroutine like so:
def hello():
print('Hello World!')
async_hello = asyncio.coroutine(hello)
However this function is deprecated as of python 3.8 (replaced by async def ...). So how can we do this in 3.8+ without async def ...?
await'ed is not always controllable from the outside.func- from a syncronous function into a coroutine -funcneeds to be called from syncronous code as well, so I can't make it async.coroutinedecorator was never meant for that usage, it was meant specifically to convert a generator into an asyncio-compatible coroutine. (I'm kind of surprised that it even works on non-generators...)asyncio.coroutineworked in the first place. But seeing how it does and is suggested on SO, I do not find its usage here particularly surprising (not that I would recommend it...).