[Python-Dev] Event loops, PyOS_InputHook, and Tkinter
"Martin v. Löwis"
martin at v.loewis.de
Sun Nov 13 14:54:48 CET 2005
Mark Hammond wrote:
> : Currently, event loops are available in Python via PyOS_InputHook, a
> : pointer to a user-defined function that is called when Python is idle
> : (waiting for user input). However, an event loop using PyOS_InputHook
> : has some inherent limitations, so I am thinking about how to improve
> : event loop support in Python.
> Either we have an unusual definition of "event loop" (as many many other
> toolkits have implemented event loops without PyOS_InputHook), or the
> requirement is for an event loop that plays nicely with the "interactive
> loop" in Python.exe.
I would guess there is an unusual definition of an "event loop". It is
probably that inside the hook, a "process_some_events()" function is
invoked, which loops until some event queue is empty; this is not the
usual infinite-loop-until-user-terminates-program. For this to work, you
need a guarantee that the hook is invoked frequently.
Again, I still think running the loop (as a true event loop) in a
separate thread would probably solve the problem.
More information about the Python-Dev