如何为Google App Engine上的BigQuery设置截止日期 [英] How to set deadline for BigQuery on Google App Engine

查看:90
本文介绍了如何为Google App Engine上的BigQuery设置截止日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google App Engine程序,用于调用BigQuery查询数据。



查询通常需要3 - 4.5秒,并且很好,但有时会花费五秒钟以上此错误:
$ b


DeadlineExceededError:API调用urlfetch.Fetch()花了很长时间回应并被取消。


这篇文章显示截止日期和不同类型的截止日期错误。



有没有方法将BigQuery作业的截止日期设置为5秒以上?无法在BigQuery API文档中找到它。

解决方案

BigQuery查询速度很快,但通常比默认App Engine urlfetch时间到。 BigQuery API是异步的,因此您需要将步骤分解为每个时间短于5秒的API调用。



对于这种情况,我会使用 App Engine任务队列


  1. 调用BigQuery API来插入您的作业。这将返回一个JobID。


  2. 在App Engine任务队列上放置一个任务,检查该ID处的BigQuery查询作业的状态。


  3. li>

    如果状态为DONE,则使用urlfetch进行调用以检索结果。



I have a Google App Engine program that calls BigQuery for data.

The query usually takes 3 - 4.5 seconds and is fine but sometimes takes over five seconds and throws this error:

DeadlineExceededError: The API call urlfetch.Fetch() took too long to respond and was cancelled.

This article shows the deadlines and the different kinds of deadline errors.

Is there a way to set the deadline for a BigQuery job to be above 5 seconds? Could not find it in the BigQuery API docs.

解决方案

BigQuery queries are fast, but often take longer than the default App Engine urlfetch timeout. The BigQuery API is async, so you need to break up the steps into API calls that each are shorter than 5 seconds.

For this situation, I would use the App Engine Task Queue:

  1. Make a call to the BigQuery API to insert your job. This returns a JobID.

  2. Place a task on the App Engine task queue to check out the status of the BigQuery query job at that ID.

  3. If the BigQuery Job Status is not "DONE", place a new task on the queue to check it again.

  4. If the Status is "DONE," then make a call using urlfetch to retrieve the results.

这篇关于如何为Google App Engine上的BigQuery设置截止日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆