In python's asyncio asynchronous programming (version 3.7 or below), if I would like to manually let a coroutine gives back its control to the main event loop , I can use this code:
@asyncio.coroutine
def switch():
yield
return
async def task():
# ...do something
# ...
await switch() # then this coroutine will be suspended and other will be triggered
# ...
# ... do something else when it's triggered again.
However in python3.8 "@coroutine" decorator is deprecated . And besides I could not use yield in a 'async def' (since it will define a async generator but not coroutine) . So how could I achive the same function?