我正在尝试并行地从远程API检索数据。远程API没有任何批量功能,因此对于我需要的每个对象,我都必须发出单独的GET请求。在
我已经把gevent加入了这个组合。有时效果很好,但如果我再次尝试相同的请求集,则100个请求中有50个会失败:
Traceback (most recent call last):
...
File "/Users/---/venv/lib/python2.7/site-packages/httplib2/__init__.py", line 1570, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/Users/---/venv/lib/python2.7/site-packages/httplib2/__init__.py", line 1317, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/Users/---/venv/lib/python2.7/site-packages/httplib2/__init__.py", line 1258, in _conn_request
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
ServerNotFoundError: Unable to find the server at my.remote.host
<Greenlet at 0x10c6eacd0: function_name(<Object1>, <Object2>, u'zebra', True)> failed with ServerNotFoundError
有什么办法解决这个问题吗?这是不是因为请求太多太快?如果是这样的话,有没有一种简单的方法来控制蔬菜的数量?在
众所周知,作为这个问题的一部分,Gevent会导致python请求的一些DNS问题(您无意中错误地标记了这些请求)。幸运的是,我们以前见过这个问题,用户resolved it是这样的
考虑到这一点,另一个用户注意到may already be fixed in a new version of gevent。在
不管上面的代码片段是否适合您,您应该尝试升级gevent以确保它不是这样的。在
相关问题 更多 >
编程相关推荐