On Jun 4, 2016, at 5:06 PM, Ben Darnell <ben@bendarnell.com> wrote:
The root of the problem is that without a standardized coroutine runner, async functions are difficult to use: each asynchronous function embeds assumptions about what runner will be used, and these assumptions will need to be documented along with instructions for what to do when you need to cross runner boundaries. We kind of have a standardized coroutine runner in async.Task, but it's inflexible, dealing only in asyncio.Futures. I think the right thing to do is to give asyncio a functools.singledispatch-based hook like the one in Tornado (tornado.gen.convert_yielded) for converting yielded objects into Futures. If we could register Tornado's Futures with asyncio then I don't think there would be a reason to prefer Tornado's coroutine runner when asyncio is available.
Looks like you, Glyph and I should work on a PEP to standardize asyncio.Task and make it more flexible. I can draft a first version (in a couple of weeks if that works), that will basically describe the current Task implementation, but I’ll need your help to make it useful for Tornado and Twisted. Thanks, Yury