Google App Engine超时? [英] Google App Engine time out?

查看:128
本文介绍了Google App Engine超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google App Engine应用程序中,我使用以下几行来从网站读取页面:

In a Google App Engine app I used the following lines to read a page from a site :

  String Url="http://...",line,Result="";

  URL url=new URL(Url+"?r="+System.currentTimeMillis());
  BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream()));

  while ((line=reader.readLine())!=null) { Result+=line+"\n"; }
  reader.close();

但我得到以下错误:

But I got the following error :

Uncaught exception from servlet
com.google.apphosting.api.DeadlineExceededException: This request (f5e2889605d27d42) started at 2011/09/07 03:20:41.458 UTC and was still executing at 2011/09/07 03:21:30.888 UTC.
    at sun.misc.Unsafe.park(Native Method)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1037)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1326)
    at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:82)
    at com.google.appengine.tools.development.TimedFuture.get(TimedFuture.java:55)
    at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:69)
    at com.google.apphosting.runtime.ApiProxyImpl.doSyncCall(ApiProxyImpl.java:177)
    at com.google.apphosting.runtime.ApiProxyImpl.access$000(ApiProxyImpl.java:56)
    at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:150)
    at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:148)
    at java.security.AccessController.doPrivileged(Native Method)

似乎花费的时间比想要等待的时间长,如果该网站很慢,我该怎么办?

Seems it took longer than it would like to wait, what can I do if that site is slow ?

推荐答案

A DeadlineExceededException 是在您的代码处理请求到您的Web应用程序需要超过30秒来处理时引发的。假设您的代码需要一段时间才能处理,因为它需要等待接收来自其他站点的数据所需的时间。

A DeadlineExceededException is thrown when your code, handling the request to your web application takes over 30 seconds to process. Presumably your code is taking a while to process because of the length of time it had to wait to receive data from some other site.

您可以在<一个href =http://code.google.com/appengine/docs/java/taskqueue/overview.html =nofollow>任务队列来获取并处理该数据,并更改您的Web请求/响应流程来回复您的任务进度。

You can create a task on a task queue to fetch and process that data, and change your web request/response flow to reply with progress on your task.

这篇关于Google App Engine超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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