Appengine任务在投掷DeadlineExceededError之前运行5秒 [英] Appengine task runs for 5 seconds before throwing DeadlineExceededError
问题描述
我最近将应用程序从使用后端转换为模块。我使用后端进行长时间运行的请求,主要是请求外部URL(使用请求库)。由于更改我的应用程序,使得一切运行在单个默认模块上,我得到了DeadlineExceededError's。即
DeadlineExceededError('API调用urlfetch.Fetch()花了很长时间回应并被取消
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屋!