Appengine任务在投掷DeadlineExceededError之前运行5秒 [英] Appengine task runs for 5 seconds before throwing DeadlineExceededError

查看:127
本文介绍了Appengine任务在投掷DeadlineExceededError之前运行5秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将应用程序从使用后端转换为模块。我使用后端进行长时间运行的请求,主要是请求外部URL(使用请求库)。由于更改我的应用程序,使得一切运行在单个默认模块上,我得到了DeadlineExceededError's。即

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

我已阅读


HTTP的60秒截止日期请求,10分钟任务截止期限

我正在运行的请求是作为任务运行的(使用deferred.defer(... ))然而,任务开始于例如15:51:54.489,并在15:51:59.600结束 - 总共5秒钟后才抛出错误。


$ b

  automatic_scaling:
min_idle_instances:1
max_idle_instances :1
max_pending_latency:1s

我不清楚为什么这个截止日期错误是抛出请告诉我如何避免抛出这个错误? 正如例外提到的,错误来自 urlfetch.Fetch ,即使您使用 urllib ,<$ c $,每个出站HTTP请求都通过App Engine路由c>请求或其他库。对于 urlfetch ,默认截止日期 5 秒。所以问题在于你对外部URL的HTTP请求超时。这似乎与您从后端切换到常规实例无关。可能是巧合。



此页

a>概述了 DeadlineExceededError 后面的各种类型的错误。


I have recently converted an app from using backends to modules. I was using backends for long running requests, primarily get requests to external url's (using the requests library). Since changing my app such that everything runs on the single default module I am getting DeadlineExceededError's. i.e.

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

I have read in the appengine documentation that there is a:

60-second deadline for HTTP requests, 10-minute deadline for tasks

The requests I am running are run as a task (using deferred.defer(...) ). However the task starts at, for example, 15:51:54.489 and finishes at 15:51:59.600 - a grand total of 5 seconds before throwing the error.

In app.yml automatic scaling enabled as follows:

automatic_scaling:
  min_idle_instances: 1
  max_idle_instances: 1
  max_pending_latency: 1s

It is not clear to me why this deadline error is being thrown. Could you please let me know how I can avoid throwing this error?

解决方案

As the exception mentions, the error is from urlfetch.Fetch, which every outbound HTTP request is routed through on App Engine, even if you use urllib, requests, or other libraries. And the default deadline for urlfetch is 5 seconds. So the problem is that your HTTP requests to external URLs are timing out. It seems unrelated to your switch from backends to regular instances. Probably a coincidence.

This page has an overview of the various types of errors behind DeadlineExceededError.

这篇关于Appengine任务在投掷DeadlineExceededError之前运行5秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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