[Twisted-Python] Deferred.setTimeout is deprecated, replacement ideas?

glyph at divmod.com glyph at divmod.com
Thu Jul 17 07:26:45 EDT 2008


On 06:44 am, gabriel.rossetti at arimaz.com wrote:
>I understand that, but sometimes whatever you're waiting on has no 
>timeout mechanism, and it's not doing any processing itself (not like a 
>database query), so quitting wouldn't hurt it. I just think maybe 
>deprecating it is a bit too harsh, maybe a big warning and 
>recommendations would be nicer :-)

Even if you are going to implement your own timeout mechanism, you need 
to do it in a layer that knows about and can compensate for the 
potential for multiple callbacks.  setTimeout's design is an invitation 
to get AlreadyCalledError tracebacks logged in your code, and to screw 
up the internal state of the API generating the Deferred.

In other words, if you have an API without a timeout mechanism, then 
write a layer above it which adds the timeout mechanism and use that.

Frankly, setTimeout has been deprecated too long: deprecating it is not 
too harsh, it is too lenient.  It should have been removed a long time 
ago :).




More information about the Twisted-Python mailing list