Twisted Deferreds (was: Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python)

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at
Sat Oct 14 13:24:26 CEST 2006

Paul Rubin wrote:

> But that's just ugly.  The fetchPage function should take the
> callback as an argument.  In an asynchronous system it would even
> be buggy. 

It won't, in my understanding/experience, since the local context
must first terminate before the reactor takes control again and
handles other events. Twisted isn't concurrent like using threads
here, and adding callbacks immediately after getting a Deferred
instance returned is common practice.

> What happens if the page fetch completes before you add the 
> callback?

If the Deferred is fired, all already added {call,err}backs will be
executed. If you add new ones at this point, they'll be executed
immediately. IIRC.



BOFH excuse #12:

dry joints on cable plug

More information about the Python-list mailing list