[Twisted-web] [twisted-web] Deferred and threads

Matthieu HUIN matthieu.huin at wallix.com
Fri Mar 19 07:05:11 EDT 2010

Hello Joson,

>From my understanding deferreds are independent from each other. Their
"progress" along their callback chain is managed by the reactor and the
way it handles and dispatches events.

There are several ways to link deferreds together if it is what you
would like to achieve :

- you can use the deferred method chainDeferred that allows you to plug
a deferred at the end of another deferred's callbacks chain;
- you can use a DeferredList instance to keep track of a list of
deferreds. It behaves as a Deferred, but you can configure it at
instanciation to either fire its callback chain as soon as one of the
deferreds in the list fires a callback, or to fire its callback chain
only after all the deferreds in the list have fired theirs (default

If you want to know more, I advise you to check the documentation; the
source code might also help.

I Hope this helps.



Le vendredi 19 mars 2010 à 18:36 +0800, Joson Mandaro a écrit :
> Hi all,
> I'm newbie and puzzled by some problems.
>           I create five deferred instances, Then when all of them get
> the responses, will they run in five threads or one by one ? I'm not
> sure to use multiple threads if they'll usually run in synchrony.
>           Best regards,
> Joson
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

More information about the Twisted-web mailing list