[Python-Dev] PEP 492: async/await in Python; version 5
tjreedy at udel.edu
Wed May 6 03:03:52 CEST 2015
On 5/5/2015 6:25 PM, Yury Selivanov wrote:
> Yes, there is no other popular event loop for 3.4 other
> than asyncio,
There is the tk(inter) event loop which also ships with CPython, and
which is commonly used.
> that uses coroutines based on generators
Oh ;-) Tkinter event loop is callback based. AFAIK, so is the asyncio
event loop, but that is somehow masked by tasks that interface to
coroutines. Do you think the 'somehow' could be adapted to work with
the tkinter loop?
What I do not understand is how io events become event loop Event
instances. For tk, keyboard and mouse actions seen by the OS become tk
Events associated with a widget. Some widgets generate events. User
code can also generate (pseudo)events.
My specific use case is to be able to run a program in a separate
process, but display the output in the gui process -- something like
this (in Idle, for instance). (Apologies if this misuses the new keywords.)
async def menu_handler()
ow = OutputWindow(args) # tk Widget
proc = subprocess.Popen (or multiprocessing equivalent)
out = (stdout from process)
await for line in out:
I want the handler to not block event processing, and disappear after
finishing. Might 492 make this possible someday? Or would having 'line
in pipe' or just 'data in pipe' translated to a tk event likely require
a patch to tk?
Terry Jan Reedy
More information about the Python-Dev