我正在尝试将从远程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对如何解决这个问题有什么想法吗?这是因为太多的要求太快吗?如果是这样的话,是否有一种简单的方法来控制绿地的数量?
发布于 2013-10-18 13:46:41
众所周知,Gevent会在python请求中引起一些DNS问题(您在不经意间错误地标记了这些请求),这是这个问题的一部分。幸运的是,我们以前见过这个问题,用户解决了这个问题如下所示
gevent.dns.resolve_ipv4('example.com')
# However you make your httplib2 call.考虑到这一点,另一个用户注意到这个可能已经在gevent的新版本中得到修正。。
不管上面的代码片段是否适合您,您都应该尝试升级gevent,以确保它不是那样的。
https://stackoverflow.com/questions/19412805
复制相似问题