Can anyone provide practical advice on how to choose between python asyncio module's Tasks and Coroutines?
If I were to achieve something asynchronously, I could do either of the 2 below -
import asyncio
@asyncio.coroutine
def print_hello():
print('Hello')
loop = asycio.get_event_loop()
loop.run_until_complete(print_hello)
loop.close()
OR
import asyncio
@asyncio.coroutine
def print_hello():
print('Hello')
print_task = asyncio.ensure_future(print_hello)
loop = asycio.get_event_loop()
loop.run_until_complete(asyncio.wait_for(print_task))
loop.close()
What factors decide which of the 2 methods above to choose?