谷歌的BigQuery api在指定的超时之前超时

时间:2017-11-12 13:14:56

标签: python google-api google-bigquery

我在Python中使用谷歌的BQ api客户端(googleapiclient),我有一个运行大约10分钟的查询...当试图获得结果时,我可以看到我在一分钟后得到一个重试的响应正在完成(我已经配置了3次重试)

  

信息:googleapiclient.discovery:请求的网址:获取https://www.googleapis.com/bigquery/v2/projects/ / queries /?timeoutMs = 300000& alt = json   警告:googleapiclient.http:在重试1/3之前休眠0.34秒以获取请求:GET https://www.googleapis.com/bigquery/v2/projects/ / queries /?timeoutMs = 300000& alt = json,之后('读取操作超时',)

我的代码如下:

from oauth2client.client import GoogleCredentials
import googleapiclient.discovery

BQ_QUERY_TIMEOUT = 300000
BQ_QUERY_RETRIES = 3

credentials = GoogleCredentials.get_application_default()
bigquery = googleapiclient.discovery.build('bigquery', 'v2', credentials=credentials)

query_data = {
        'query': query,
        'useLegacySql': use_legacy_sql
    }

query_job = bigquery.jobs().query(projectId=BQ_PROJECT_ID, body=query_data).execute()
    page_token = None
    while True:
        page = bigquery.jobs().getQueryResults(pageToken=page_token, timeoutMs=BQ_QUERY_TIMEOUT, **query_job['jobReference']).execute(num_retries=BQ_QUERY_RETRIES)
        for row in page.get('rows', []):
            yield row
        page_token = page.get('pageToken')
        if not page_token:
            break

查询在完全一分钟之后超时,然后重试3次,我无法获得结果..

有什么想法?我做错了吗?

0 个答案:

没有答案