Create a continuation that executes when the Future is completed.

        :param continuation_func: A function which takes the future as the only parameter. Return value of the function
        will be set as the result of the continuation future.
        :return: A new Future which will be completed when the continuation is done.

def continue_with(self, continuation_func, *args):
        """
        Create a continuation that executes when the Future is completed.

        :param continuation_func: A function which takes the future as the only parameter. Return value of the function
        will be set as the result of the continuation future.
        :return: A new Future which will be completed when the continuation is done.
        """
        future = Future()

        def callback(f):
            try:
                future.set_result(continuation_func(f, *args))
            except:
                future.set_exception(sys.exc_info()[1], sys.exc_info()[2])

        self.add_done_callback(callback)
        return future