[Twisted-Python] gtk2reactor: scheduling work in the immediate future without throttling gtk

Thomas Vander Stichele thomas at apestaart.org
Sun Apr 18 05:11:58 MDT 2010


Hi.  My use case is pretty simple:

 - my UI has a throbber that gets activated while I'm querying a CouchDB
server and populating the UI with results, which can be many.
 - when iterating over the results, I want the UI to keep throbbing,
which means the gtk mainloop needs to be regularly scheduled by
gtk2reactor
 - if I iterate over the results and create a deferred chain and fire
it, the whole update of the UI still gets executed synchronously, not
giving the gtk mainloop time to throb.
 - if I do it with callLater(0, ...), again these calls get executed
ASAP and throttle the main loop

Every other workaround I can think of is ugly (using random.random() as
the argument to callLater to space calls, using a counter to space out
calls, doing callLater from the next call chain, ...)

In reality, all I want is to schedule a call to be processed with lower
priority than the main loop; ie, have the reactor run GTK's mainloop
then process my calls.  This way, I could create a chain of say 10 calls
at a time, and give the mainloop time to run between each block.

Is something like this possible at all ? How do the other reactors
handle this ? Why is priority given to the twisted DelayedCalls ?

Thomas

-- 
in the twist of separation
you excelled at being free
--
GStreamer - bringing multimedia to your desktop
http://gstreamer.freedesktop.org/






More information about the Twisted-Python mailing list