def instantiateAddCallbacksBeforeResult(n):
 d = defer.Deferred()
 def f(result):
  return result
 for i in xrange(n):
  d.addCallback(f)
  d.addErrback(f)
  d.addBoth(f)
  d.addCallbacks(f)
 d.callback(1)

def instantiateAddCallbacksBeforeResult ( n ) : d = defer . Deferred ( ) def f ( result ) : return result for i in xrange ( n ) : d . addCallback ( f ) d . addErrback ( f ) d . addBoth ( f ) d . addCallbacks ( f ) d . callback ( 1 )
create a deferred and adds a trivial callback/errback/both to it the given number of times .