Recipe request: asyncio "spin off coroutine"

Marko Rauhamaa marko at pacujo.net
Wed Dec 14 15:25:19 EST 2016


Chris Angelico <rosuav at gmail.com>:

> On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> Chris Angelico <rosuav at gmail.com>:
>>
>>>     asyncio.spin_off(parallel()) # ???
>>>
>>> [...]
>>>
>>> What code should go on the "???" line to accomplish this?
>>
>> asyncio.ensure_future(parallel())
>
> Hmm. I tried that but it didn't work in the full program (it hung the
> calling coroutine until completion). But it does work in the toy
> example I posted here. Weird. Must be something else that's wrong,
> then. I'll keep poking around, thanks.

What version of Python are you running?

   Changed in version 3.5.1: The function accepts any awaitable object.

   <URL: https://docs.python.org/3/library/asyncio-task.html#asyncio.ensu
   re_future>


Marko



More information about the Python-list mailing list