[Twisted-Python] non-blocking and non-blocking.

Itamar Shtull-Trauring lists at itamarst.org
Wed Nov 14 02:25:42 MST 2001


Kevin Turner wrote:

> So, if you run something like the following through manhole:
> 
> def spam(n=300):
>     for i in xrange(n):
>         print "iiIiiIiI", i
> 
> spam()
> 
> the whole mess comes back when the command has finished completion, and
> receiving that much data seems to take the protocol-decoder a while to
> decode.  Long enough that it can cause a hiccup, or outright stall, in
> the GUI.  So it might be nice to do that processing in incremental bit
> so it shares time better.  In twisted.python terms, it'd be in a Looping
> construct, or in GTK terms, you'd add it on an idle handler.


Or, you could return a Deferred and dispatch the action to be done by a 
ThreadDispatcher.









More information about the Twisted-Python mailing list