[Python-ideas] The async API of the future

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Oct 20 05:11:08 CEST 2012


Jasper St. Pierre wrote:
> For most windowing systems, this isn't true. You need to call some
> function to check if you have events pending. For X11, this is
> "XPending". For Win32, this is "GetQueueStatus".

X11 is ultimately reading its events from the socket to
the display server. If you select() that socket, it will
tell you whenever the X11 event loop could possibly have
something to do.

On Windows, I imagine the equivalent would be to pass your
message queue handle to a WaitForMultipleObjects call.
I've never tried to do anything like that, though, so
I don't know if it would really work.

> What Twisted does is this case is swap out their own select
> loop with another implementation built around GLib's GMainLoop,

If it's truly impossible to incorporate GMainLoop as a
sub-loop of something else, then this is a bad situation.
What happens if you also want to use some other library
that insists on *its* main loop being in charge? This
cannot be a general solution.

-- 
Greg



More information about the Python-ideas mailing list