【问题标题】:App Engine Python UrlFetch.set_default_fetch_deadlineApp Engine Python UrlFetch.set_default_fetch_deadline
【发布时间】:2015-10-05 16:47:16
【问题描述】:

我浏览了这里的文档: https://cloud.google.com/appengine/docs/python/urlfetch/ 和这里: https://cloud.google.com/appengine/articles/deadlineexceedederrors?hl=en

我还发现了这个与我的问题有关的堆栈溢出问题: How to set timeout for urlfetch in Google App Engine?

我正在从我的应用引擎应用程序连接到我无法控制的外部 Web 服务。有时请求需要超过 60 秒。我将我的应用程序设置为使用延迟的应用程序引擎任务队列 api。

我很困惑。在我读过的文档中,似乎 urlfetch 的最大截止日期为 60 秒。但是如果它在 task_queue 中运行是 10 分钟?我真的只需要有人为我澄清这一点。

这是否意味着任务有 10 分钟才能完成,但任务内部的 urlfetch 仍然限制在 60 秒?

伪代码:

myTask = newTask()
deffered.defer(myTask.long_process, _queue="myqueue")

class newTask:
    url = "https://example.com"
def long_process(self):
    #will setting the deadline to more than 60 seconds work or not? 
    urlfetch.set_default_fetch_deadline(120)
    data = {}
    resp = urlfetch.fetch(self.url, method="POST", payload=data)
    #do something with resp....

【问题讨论】:

    标签: python google-app-engine task-queue urlfetch


    【解决方案1】:

    你在正确的轨道上。小修正:urlfetch.set_default_fetch_deadline() 没有 60 秒的最大值,你可能被讨论的上下文误导了。

    您可以将 120 的值提高到 600,请参阅 OP 在最近的问答中对所选答案的评论:Appengine task runs for 5 seconds before throwing DeadlineExceededError

    【讨论】:

    • 您是否知道任何文档明确指出您可以将 urlfetch 超时时间增加到 60 秒以上?
    • 不,我不知道。
    【解决方案2】:

    您可以控制 urlfetch 和延迟任务的截止日期。

    两者都可以运行长达 600 秒的 AFAIK。

    您不应该做的一件事是将 urfetch 截止日期设置为比任务更高的值;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-24
      • 2018-01-14
      • 2012-04-27
      • 2011-04-20
      • 1970-01-01
      • 2012-12-20
      • 2011-10-20
      • 2012-04-14
      相关资源
      最近更新 更多