

def wait_for_job(self, job, interval=5, timeout=60):
    '\n        Waits until the job indicated by job_resource is done or has failed\n\n        Parameters\n        ----------\n        job : Union[dict, str]\n            ``dict`` representing a BigQuery job resource, or a ``str``\n            representing the BigQuery job id\n        interval : float, optional\n            Polling interval in seconds, default = 5\n        timeout : float, optional\n            Timeout in seconds, default = 60\n\n        Returns\n        -------\n        dict\n            Final state of the job resouce, as described here:\n            https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/bigquery_v2.jobs.html#get\n\n        Raises\n        ------\n        Union[JobExecutingException, BigQueryTimeoutException]\n            On http/auth failures or timeout\n        '
    complete = False
    job_id = str((job if isinstance(job, (six.binary_type, six.text_type, int)) else job['jobReference']['jobId']))
    job_resource = None
    start_time = time()
    elapsed_time = 0
    while (not (complete or (elapsed_time > timeout))):
        sleep(interval)
        request = job_resource.bigquery.jobs().get(projectId=self.project_id, jobId=job_id)
        job_resource = request.execute()
        self._raise_executing_exception_if_error(job_resource)
        complete = (job_resource.get('status').get('state') == 'DONE')
        elapsed_time = (time() - start_time)
    if (not complete):
        logger.error(('BigQuery job %s timeout' % job_id))
        raise BigQueryTimeoutException()
    return job_resource

dataset/ETHPy150Open tylertreat/BigQuery-Python/bigquery/client.py BigQueryClient.wait_for_job/VarMisuse@97/386 `self`->`job_resource`