dev_appserver.py中的App引擎URLError下载错误。 "无法分配请求的地址"

时间:2014-05-16 22:09:44

标签: python google-app-engine ubuntu ubuntu-12.04

我正在尝试下载一个大型远程文件,并且收到一个新错误..我以前从未见过这个,当我把它放入浏览器时,我正在尝试使用的URL。

我使用以下网址请求网址:

    startDownloadTime = datetime.datetime.now()
    logging.info("Download Start Time: "+startDownloadTime.strftime("%H:%M.%S"))
    url = [MY URL]
    logging.info("Starting download")
    r = requests.get(url)
    logging.info("Download complete") 

以下是完整的跟踪:

URLError: <urlopen error [Errno 99] Cannot assign requested address>
Traceback (most recent call last):
  File "/home/username/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
req.respond()
  File "/home/username/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
self.server.gateway(self).respond()
  File "/home/username/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
response = self.req.server.wsgi_app(self.env, self.start_response)
  File "/home/username/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 269, in __call__
return app(environ, start_response)
  File "/home/username/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 311, in _rewriter_middleware
response_body = iter(application(environ, wrapped_start_response))
  File "/home/username/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 149, in __call__
self._flush_logs(response.get('logs', []))
  File "/home/username/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 264, in _flush_logs
apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
  File "/home/username/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
return stubmap.MakeSyncCall(service, call, request, response)
  File "/home/username/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 328, in MakeSyncCall
rpc.CheckSuccess()
  File "/home/username/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
self.request, self.response)
  File "/home/username/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall
self._MakeRealSyncCall(service, call, request, response)
  File "/home/username/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 226, in _MakeRealSyncCall
encoded_response = self._server.Send(self._path, encoded_request)
  File "/home/username/google_appengine/google/appengine/tools/appengine_rpc.py", line 409, in Send
f = self.opener.open(req)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
'_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1177, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 99] Cannot assign requested address>

这是一个大文件,所以我发现自己不得不使用套接字来下载它,所以这个app.yaml文件有:

env_variables:
   GAE_USE_SOCKETS_HTTPLIB : 'anyvalue'

在里面。有什么想法吗?

编辑:只是想补充一点,这是针对本地开发服务器的,并且可以在我的生产代码中使用。

编辑2 :只是为了添加 - 该脚本在崩溃之前工作了几分钟,所以它似乎正在尝试下载文件..

1 个答案:

答案 0 :(得分:0)

我刚刚解决了这个问题 - 我的端口耗尽并增加了端口范围:

$ sudo sysctl -w net.ipv4.ip_local_port_range="15000 61000"

它开始工作了。