def _chain_result(outer_future):
    """Returns a callable that can be supplied to Future.add_done_callback
    to propagate a future's result to outer_future.

    """
    def f(inner_future):
        try:
            result = inner_future.result()
        except BaseException as e:
            outer_future.set_exception(e)
        else:
            outer_future.set_result(result)
    return f