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