我用开发了一个应用程序,但我有一个问题。这个项目是一个研究项目,我几乎没有什么重要的功能。统计分析,自然语言处理等。
几乎没有几个函数需要超过20秒才能完成。
其中之一是一个网站的api,在那里我调用一个链接,它返回一个字典。但是,当我调用它时,在4-5秒之后,浏览器停止加载并返回一个空值。没别的了。
如果我脱机运行函数,在服务器之外,作为一个简单的python函数,我将在10-15秒后得到结果。
是否有任何方法来增加加载时间或其他东西来解决我的问题?
发布于 2013-08-21 16:05:32
在Google中,每个请求都有30秒的困难超时时间,因此如果您需要更多的时间,您将不得不使用任务队列API或后端API。
不过,实现目标的最简单方法是使用递延库,这是一个简单得多的包装器,而不是乱搞Task。在您的- deferred: on中插入app.yaml之后,您可以这样做(从文档中):
from google.appengine.ext import deferred
def do_something_expensive(a, b, c=None):
logging.info("Doing something expensive!")
# Do your work here
# Somewhere else
deferred.defer(do_something_expensive, "Hello, world!", 42, c=True)但是,由于任务将在您的请求之后完成,所以您必须在Datastore中的某个地方写入结果,以便稍后检索它。
发布于 2013-08-22 06:09:42
实际上,听起来你是先到了urlFetch超时。
https://developers.google.com/appengine/docs/python/urlfetch/
You can set a deadline for a request, the most amount of time the
service will wait for a response. By default, the deadline for a
fetch is 5 seconds. The maximum deadline is 60 seconds for HTTP
requests and 10 minutes for task queue and cron job requests.更新:您可以使用截止日期属性来设置它。
https://developers.google.com/appengine/docs/python/urlfetch/fetchfunction
https://stackoverflow.com/questions/18361879
复制相似问题