Python'请求'模块导致ConnectionError

时间:2015-02-20 10:50:04

标签: python python-requests cherrypy

我有一个网络应用程序,以前在本地工作得非常好,直到我把它放在服务器上,我必须在本地安装必要的软件包(包括Python'请求'),因为我没有root访问权限。 我在服务器上运行应用程序后,它开始工作正常,某些类型的查询返回正确的输出。虽然涉及到需要使用我的wsgi中的某些功能的查询,包括使用'请求'模块,产生错误:

Traceback (most recent call last):
  File "/home/usrname/SEMWEB/simple/app.py", line 206, in _app
    req = get(url, verify=False)
  File "/home/usrname/.local/lib/python2.7/site-packages/requests-2.5.1-py2.7.egg/requests/api.py", line 65, in get
    return request('get', url, **kwargs)
  File "/home/usrname/.local/lib/python2.7/site-packages/requests-2.5.1-py2.7.egg/requests/api.py", line 49, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/home/usrname/.local/lib/python2.7/site-packages/requests-2.5.1-py2.7.egg/requests/sessions.py", line 461, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/usrname/.local/lib/python2.7/site-packages/requests-2.5.1-py2.7.egg/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/home/usrname/.local/lib/python2.7/site-packages/requests-2.5.1-py2.7.egg/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

我使用Cherrypy,我在wsgi文件中调用如下:

if __name__ == '__main__':

    wsgi_app = RdfDemoApp("http://localhost:3030/ds/query")

    try:
        server = CherryPyWSGIServer(('0.0.0.0',8000), wsgi_app)
        server.start()

0 个答案:

没有答案