Add sleep to prevent throttling

This commit is contained in:
Yue Zhang
2015-09-12 13:24:12 +08:00
parent 67c6fdb798
commit a443bf6f04
+5
View File
@@ -123,10 +123,15 @@ def _fetch_uri(uri, headers, chk_proxy=False):
except restutil.HttpError as e:
raise ProtocolError(text(e))
if(resp.status == httpclient.FORBIDDEN):
logger.info("Sleep to prevent throttling.")
time.sleep(10)
if(resp.status == httpclient.GONE):
raise WireProtocolResourceGone(uri)
if(resp.status != httpclient.OK):
raise ProtocolError("{0} - {1}".format(resp.status, uri))
data = resp.read()
if data is None:
return None