[Twisted-Python] conceptually, why a deferred can't be used more than once?

Andrew Bennetts andrew at bemusement.org
Thu Jul 8 23:06:13 MDT 2010


Jean Daniel wrote:
> Dear list,
> 
> Concerning the concept of the deferred, why is it more useful to go
> with a deferred which gets consumed and can only be fired once?

Because they are basically a way to provide asynchronous function calls.  In
plain Python a function call only returns (or raises) once.  Deferreds are no
different.

If you want a callback that can be invoked multiple times... well, just pass a
function to the thing generating callbacks.  For instance, Protocol objects have
a dataReceived method that may be called many times.

-Andrew.




More information about the Twisted-Python mailing list