Guido van Rossum, in his speech in 2014 on Tulip/Asyncio shows the slide:
Tasks vs coroutines
Compare:
For the calling side co-routine yield from coroutine()
feels like a function call (i.e. it will again gain control when coroutine() finishes).
yield from Task(coroutine())
on the other hand feels more like creating a new thread. Task()
returns almost instantly and very likely the caller gains control back before the coroutine()
finishes.
The difference between f()
and th = threading.Thread(target=f, args=()); th.start(); th.join()
is obvious, right?