def _PollJob(
    apitools_client, messages_module, job_reference, status='DONE', wait=0):
  """Poll a job once for a specific status.

  Arguments:
    apitools_client: Client to be used for the poll.
    messages_module: The module defining messages used in apitools calls.
    job_reference: JobReference to poll.
    status: (optional, default 'DONE') Desired job status.
    wait: (optional, default 0) Max server-side wait time for one poll call.

  Returns:
    Tuple (in_state, job) where in_state is True if job is
    in the desired state.

  Raises:
    ValueError: If given an invalid wait value.
  """
  try:
    int(wait)
  except ValueError:
    raise ValueError('Invalid value for wait: {0}'.format(wait))
  request = messages_module.BigqueryJobsGetRequest(
      jobId=job_reference.jobId,
      projectId=job_reference.projectId)
  job = apitools_client.jobs.Get(request)
  current = job.status.state
  return (current == status, job)