def invoke_sync_timeout(executor, timeout, result_fn, call_fn, *args):
    """
    invoke synchronously with timeout.  This method uses the given executor
    to submit call_fn/*args and then after result has been returned (with given timeout)
    the result_fn is optionally called with the returned result, executor, timeout, call_fn
    must not be None.  
    """
    if not executor:
        raise Exception('cannot submit call_fn={0} without executor'.format
            (call_fn))
    call_result = executor.submit(call_fn, *args).result(timeout)
    if result_fn:
        return result_fn(call_result)
    return call_result
