GoogleAppEngine urlfetch超时异常 [英] GoogleAppEngine urlfetch timeout exception
问题描述
DownloadError:ApplicationError:2超时
我正在尝试发送HTTP POST请求。像这样:
result = urlfetch.fetch('http://api.nathan.com:8080/Obj/'
method ='POST',
payload = postdata,
deadline = 10)
我已经尝试将最后期限设置为最大(10秒)。来自命令行的请求(使用curl或httplib2)需要大约一秒钟。
nchong @ almond〜$ time curl
-d< obj< a> 1< / a>< b> n< / b>< / Obj&
http://api.nathan.com:8080/Obj/
agd1c2VyYXBpcgoLEgRTZXNzGAIM#<钥匙由
真实返回0m1.109s
用户0m0.003s
sys 0m0.009s
这是开发应用服务器的curl请求的输出(我使用的是appengine-rest-server):
INFO __init__.py:819]从模块__main__
INFO __init__.py:867添加模型添加模型Obj,类型为< class'__main __。Obj >
INFO dev_appserver.py:3243]POST / Obj HTTP / 1.1200 -
INFO dev_appserver_index.py:205]更新/path/to/index.yaml
当我尝试使用urlfetch时,这是输出:
ERROR __init__.py:388] ApplicationError:2超时
追溯(最近的最后一次调用):
文件/path/to/webapp/__init__.py,第507行, __call__
handler.get(* groups)
文件/path/to/myapp/main.py,第62行,get
result = urlfetch.fetch(...)
文件/path/to/urlfetch.py,行241,在fetch
中返回rpc.get_result()
文件/path/to/apiproxy_stub_map.py,第501行, get_result
return self .__ get_result_hook(self)
文件/path/to/urlfetch.py,第325行,_get_fetch_result
raise DownloadError(str(err))
DownloadError :ApplicationError:2超时
INFO dev_appserver.py:3243]GET / HTTP / 1.1500 -
INFO dev_appserver.py:3243]POST / Obj / HTTP / 1 .1200 -
开发Web服务器是单-threaded。您不能向您自己的应用程序发出请求。尝试在不同端口上运行两个实例。
顺便说一句,部署后这不应该是一个问题,因为实际的AppEngine服务器当然可以处理多个同时请求。
Has anyone got any experience with the following exception when using GAE urlfetch?
DownloadError: ApplicationError: 2 timed out
I'm trying to send a HTTP POST request. Like so:
result = urlfetch.fetch('http://api.nathan.com:8080/Obj/',
method='POST',
payload=postdata,
deadline=10)
I've tried setting deadline to the max (10 seconds). The request from the command line (using curl or httplib2) takes about a second.
nchong@almond ~ $ time curl
-d "<Obj><a>1</a><b>n</b></Obj>"
http://api.nathan.com:8080/Obj/
agd1c2VyYXBpcgoLEgRTZXNzGAIM #< key returned by call
real 0m1.109s
user 0m0.003s
sys 0m0.009s
Here's the output from the dev appserver for the curl request (I'm using appengine-rest-server):
INFO __init__.py:819] adding models from module __main__
INFO __init__.py:867] added model Obj with type <class '__main__.Obj'>
INFO dev_appserver.py:3243] "POST /Obj HTTP/1.1" 200 -
INFO dev_appserver_index.py:205] Updating /path/to/index.yaml
Here's the output when I try to use urlfetch:
ERROR __init__.py:388] ApplicationError: 2 timed out
Traceback (most recent call last):
File "/path/to/webapp/__init__.py", line 507, in __call__
handler.get(*groups)
File "/path/to/myapp/main.py", line 62, in get
result = urlfetch.fetch(...)
File "/path/to/urlfetch.py", line 241, in fetch
return rpc.get_result()
File "/path/to/apiproxy_stub_map.py", line 501, in get_result
return self.__get_result_hook(self)
File "/path/to/urlfetch.py", line 325, in _get_fetch_result
raise DownloadError(str(err))
DownloadError: ApplicationError: 2 timed out
INFO dev_appserver.py:3243] "GET / HTTP/1.1" 500 -
INFO dev_appserver.py:3243] "POST /Obj/ HTTP/1.1" 200 -
The development web server is single-threaded. You can not make a request from your application running inside it to itself. Try running two instances on different ports.
By the way, this should not be a problem once it is deployed, as the actual AppEngine server is of course able to handle multiple simultaneous requests.
这篇关于GoogleAppEngine urlfetch超时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!