You can't have it both ways. If it's a coroutine, you can't get its result
in the callback. But that shouldn't be a problem -- you can just put any
processing of the result you need in the coroutine. In effect, the only
purpose of the callback then is to start the coroutine running. If you have
an
How do you unwrap the result of the coroutine wrapped in the task though?
On Wednesday, August 5, 2015 at 4:02:24 AM UTC-6, Guido van Rossum wrote:
>
> To start a coroutine from a callback, you wrap the coroutine in a Task.
> That's all. E.g. (untested)
>
> from asyncio import coroutine, get_eve
To start a coroutine from a callback, you wrap the coroutine in a Task.
That's all. E.g. (untested)
from asyncio import coroutine, get_event_loop
@coroutine
def coro():
...
yield from something()
...
# callback
def heartbeat():
get_event_loop().create_task(coro())
get_event_l