'Waits for the Job to reach a terminal state.
This method will periodically check the job state until the job reach
a terminal state.
Raises:
apiclient.errors.HttpError: if HTTP error is returned when getting
the job'

def _wait_for_job_done(self, project_id, job_id, interval=30):

    assert (interval > 0)
    while True:
        job = self._get_job(project_id, job_id)
        if (job['state'] in ['SUCCEEDED', 'FAILED', 'CANCELLED']):
            return job
        time.sleep(interval)
