[Python-Dev] PEP 550 v4: coroutine policy

Nathaniel Smith njs at pobox.com
Tue Aug 29 16:18:51 EDT 2017


On Tue, Aug 29, 2017 at 12:59 PM, Yury Selivanov
<yselivanov.ml at gmail.com> wrote:
>     b2 = wait_for(bar())
>     # bar() was wrapped into a Task and is being running right now
>     await b2

Ah.... not quite. wait_for is itself implemented as a coroutine, so it
doesn't spawn off bar() into its own task until you await b2.

Though according to the docs you should pretend that you don't know
whether wait_for returns a coroutine or a Future, so what you said
would also be a conforming implementation.

-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Python-Dev mailing list