[Async-sig] A possible tiny step towards event loop interoperability

Nathaniel Smith njs at pobox.com
Fri Jun 3 21:33:54 EDT 2016


On Fri, Jun 3, 2016 at 6:16 PM, Ben Darnell <ben at bendarnell.com> wrote:
> On Fri, Jun 3, 2016 at 9:14 PM, Nathaniel Smith <njs at pobox.com> wrote:
>>
>> On Fri, Jun 3, 2016 at 6:10 PM, Ben Darnell <ben at bendarnell.com> wrote:
>> > The introduction of `await` has imposed similar restrictions on both
>> > systems, so there is no more yielding of lists or dicts in either case;
>> > explicit wrapper objects must be used. (but there's still a difference
>> > in
>> > that asyncio.Task allows None but tornado coroutines do not)
>>
>> I'm not saying that yielding lists or dicts is useful, but it sounds
>> like you're saying that somehow it's actually incompatible with
>> async/await, and I don't understand why that would be -- e.g., this
>> works fine?:
>
>
> Yes, this works fine as long as you have the extra hop into a decorated
> coroutine. What you can't do is `await [1, 2, 3]` in an `async def` native
> coroutine.

Ahh, gotcha. So the constraint is that the final 'await' always has to
go through special awaitable object -- but there's no constraint on
what kinds of objects the leaf awaitable and the coroutine runner pass
back and forth to communicate.

-n

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


More information about the Async-sig mailing list