code: def chain_future(a, b):
      """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.
      """
  
      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)
  
imports: from __future__ import absolute_import, division, print_function
  import functools
  import platform
  import textwrap
  import traceback
  import sys
  from tornado.log import app_log
  from tornado.stack_context import ExceptionStackContext, wrap
  from tornado.util import raise_exc_info, ArgReplacer, is_finalizing
label_desc: Use image node_id 4 for calling a global function with example usage: chain_future(a, b) without return types