code: 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)
docs: Chain two futures together so that when one completes, so does the other.
  
      The result (success or failure) of ``a`` will be copied to ``b``, unless
      ``b`` has already been completed or cancelled by the time ``a`` finishes.