[Twisted-Python] Timing Out Deferreds
![](https://secure.gravatar.com/avatar/0f75ce870b16161d65b0c65d02159fe3.jpg?s=120&d=mm&r=g)
I've been trying to figure out an intelligent way of timing out deferreds. I'd like something like this... def myTimeoutMethod(...): ... d = whatnot() d.addCallback(...) d.addErrback(...) d.addTimeout(5, myTimeoutMethod) There are obvious problems with trying to interrupt an existing deferred, but I was hoping there might be just some way of discarding its data when it finally does return, or dereferencing the deferred object itself from the reactor, which might just let it clean itself up on its own. Thoughts? -Ken
![](https://secure.gravatar.com/avatar/15fa47f2847592672210af8a25cd1f34.jpg?s=120&d=mm&r=g)
On Feb 25, 2005, at 2:53 PM, Ken Kinder wrote:
I've been trying to figure out an intelligent way of timing out deferreds.
No, a deferred is just a chain of callbacks -- it doesn't really make sense to time out a chain of callbacks. You need to time out the *source* operation that is planning on eventually calling the deferred. The process of killing the source operation ought to additionally cause the deferred's errback to be called. James
![](https://secure.gravatar.com/avatar/15fa47f2847592672210af8a25cd1f34.jpg?s=120&d=mm&r=g)
On Feb 25, 2005, at 2:53 PM, Ken Kinder wrote:
I've been trying to figure out an intelligent way of timing out deferreds.
No, a deferred is just a chain of callbacks -- it doesn't really make sense to time out a chain of callbacks. You need to time out the *source* operation that is planning on eventually calling the deferred. The process of killing the source operation ought to additionally cause the deferred's errback to be called. James
participants (3)
-
Itamar Shtull-Trauring
-
James Y Knight
-
Ken Kinder