def timeoutDeferred(reactor, deferred, seconds):
 def timedOutCall():
  deferred.cancel()
 delayedTimeOutCall = reactor.callLater(seconds, timedOutCall)
 def cancelTimeout(result):
  if delayedTimeOutCall.active():
   delayedTimeOutCall.cancel()
  return result
 deferred.addBoth(cancelTimeout)
 return delayedTimeOutCall

def timeoutDeferred ( reactor , deferred , seconds ) : def timedOutCall ( ) : deferred . cancel ( ) delayedTimeOutCall = reactor . callLater ( seconds , timedOutCall ) def cancelTimeout ( result ) : if delayedTimeOutCall . active ( ) : delayedTimeOutCall . cancel ( ) return result deferred . addBoth ( cancelTimeout ) return delayedTimeOutCall
cancel a l{deferred} if it does not have a result available within the given amount of time .