import time


def wait_for_job(res, ping_time=0.5):
    """
    Blocks execution and waits for an async Forest Job to complete.

    :param JobResult res: The JobResult object to wait for.
    :param ping_time: The interval (in seconds) at which to ping the server.
    :return: The completed JobResult
    """
    while not res.is_done():
        res.get()
        time.sleep(ping_time)
    return res