def _wait_for_query_job(
    connector,
    client: bigquery.Client,
    query_reply: bigquery.QueryJob,
    timeout_ms: Optional[float],
):
    """Wait for query to complete, pausing occasionally to update progress.

    Args:
        connector (GbqConnector):
            General pandas-gbq "connector" with helpers for stateful progress
            logs and error raising.

        client (bigquery.Client):
            A connection to BigQuery, used to make API requests.

        query_reply (QueryJob):
            A query job which has started.

        timeout_ms (Optional[int]):
            How long to wait before cancelling the query.
    """
    # Wait at most 10 seconds so we can show progress.
    # TODO(https://github.com/googleapis/python-bigquery-pandas/issues/327):
    # Include a tqdm progress bar here instead of a stream of log messages.
    timeout_sec = 10.0
    if timeout_ms:
        timeout_sec = min(timeout_sec, timeout_ms / 1000.0)

    while query_reply.state != "DONE":
        connector.log_elapsed_seconds("  Elapsed", "s. Waiting...")

        if timeout_ms and timeout_ms < connector.get_elapsed_seconds() * 1000:
            client.cancel_job(query_reply.job_id, location=query_reply.location)
            raise pandas_gbq.exceptions.QueryTimeout(
                "Query timeout: {} ms".format(timeout_ms)
            )

        try:
            query_reply.result(timeout=timeout_sec)
        except concurrent.futures.TimeoutError:
            # Use our own timeout logic
            pass
        except connector.http_error as ex:
            connector.process_http_error(ex)
Wait for query to complete, pausing occasionally to update progress.

    Args:
        connector (GbqConnector):
            General pandas-gbq "connector" with helpers for stateful progress
            logs and error raising.

        client (bigquery.Client):
            A connection to BigQuery, used to make API requests.

        query_reply (QueryJob):
            A query job which has started.

        timeout_ms (Optional[int]):
            How long to wait before cancelling the query.
    
pandas_gbq/query.py