def chain_future(a, b):
 def copy(future):
  assert (future is a)
  if b.done():
   return
  if (isinstance(a, TracebackFuture) and isinstance(b, TracebackFuture) and (a.exc_info() is not None)):
   b.set_exc_info(a.exc_info())
  elif (a.exception() is not None):
   b.set_exception(a.exception())
  else:
   b.set_result(a.result())
 a.add_done_callback(copy)

def chain_future ( a , b ) : def copy ( future ) : assert ( future is a ) if b . done ( ) : return if ( isinstance ( a , TracebackFuture ) and isinstance ( b , TracebackFuture ) and ( a . exc_info ( ) is not None ) ) : b . set_exc_info ( a . exc_info ( ) ) elif ( a . exception ( ) is not None ) : b . set_exception ( a . exception ( ) ) else : b . set_result ( a . result ( ) ) a . add_done_callback ( copy )
chain two futures together so that when one completes .