[Python-ideas] How the heck does async/await work in Python 3.5

Nick Coghlan ncoghlan at gmail.com
Wed Feb 24 20:05:33 EST 2016


On 25 February 2016 at 06:57, Terry Reedy <tjreedy at udel.edu> wrote:
> On 2/24/2016 4:59 AM, Paul Moore wrote:
>>
>> On 24 February 2016 at 02:37, Terry Reedy <tjreedy at udel.edu> wrote:
>>>
>>>
>>> In this essay, Brett says that asyncio added an event loop to Python. It
>>> did, but it was the second.  The tk event loop was added about 20 years
>>> ago
>>> with tkinter.
>>
>> One of the things I would love to see (but don't have the time to work
>> on) is a GUI event loop based around async/await. It would be a very
>> useful example to make it clear to people that async/await isn't just
>> about network protocols.
>
> Aiming at this was part of the point of my closing comment about adapting
> generators to the tk mainloop callback interface.  The next step would be to
> do the same for awaitables.  However, I need more study of the details of
> asyncio and the async/await protocol.

Letting GUI event loops take over running awaitables is part of the
rationale for the event loop management features in asyncio:
https://docs.python.org/3/library/asyncio-eventloops.html

Having an event loop interface adapter in the stdlib tk modules that
can be used with asyncio.set_event_loop() would provide a much clearer
demonstration of the full power of that approach than the current
"*nix selectors vs Windows IOCP" capability (the latter is useful, but
doesn't cover the "integration with an existing 3rd party event loop"
use case).

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list