Twisted Deferreds (was: Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python)
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sat Oct 14 07:24:26 EDT 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.
http://twistedmatrix.com/projects/core/documentation/howto/async.html
http://twistedmatrix.com/projects/core/documentation/howto/defer.html
Regards,
Björn
--
BOFH excuse #12:
dry joints on cable plug
More information about the Python-list
mailing list