[Twisted-Python] why deferred.setTimeout is not my favorite API method

Bob Ippolito bob at redivi.com
Sun Apr 18 11:21:45 EDT 2004

On Apr 18, 2004, at 6:16 AM, Andrew Bennetts wrote:

> On Sun, Apr 18, 2004 at 04:21:11AM +0000, exarkun at divmod.com wrote:
>>   I tend to prefer "foo(x, y, timeout=z)" over "foo(x, 
>> y).setTimeout(z)".
>>   As both require explicit support from the implementor of "foo" (as 
>> you
>>   correctly note is the only way .setTimeout() can actually work), it
>>   seems unnecessary to special-case this form of failure in 
>> Deferreds.  I
>>   cast my vote for the former.
> I think that timeouts, or cancellations in general, are something that
> Deferreds should *support*, even though they cannot provide them 
> entirely
> automatically.  I'll try to explain why.

Yes, cancellation should be supported in the Deferred object, timeouts 
should not.  Timeouts are just a specific case of cancellation that can 
be done outside of the implementation of Deferred.  Cancellation can't, 
because you need to know where the deferred came from originally in 
order to figure out how to cancel it and that information is not 


More information about the Twisted-Python mailing list