0
我試圖從遠程API中並行檢索數據。遠程API沒有任何批量功能,因此對於我需要的每個對象,我必須提出一個單獨的GET請求。使用gevent/greenlets請求時獲取ServerNotFoundError
我已將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
的方式有什麼想法來解決這個問題?這是太多請求的結果嗎?如果是這樣,是否有一個簡單的方法來節制greenlet的數量?