ISBNLibHTTPError: an HTTP error has ocurred (429 Are you making many requests?) for isbnlib.isbn_from_words()
raajtilaksarma opened this issue · comments
The above error is seen while using the function isbnlib.isbn_from_words().
Is my IP permanently blocked or is this a temporary thing?
What are the limits of number of calls to this function. A detailed solution could be beneficial to get around this error.
Hi,
This is only temporary and happens when you make more than one call per second!
What is the time for it to not stop blocking? It has been 24 hours and still the error persists.
However if i try from a different machine, i do not get an error.
This is the trace.
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/isbnlib/dev/webservice.py in response(self)
47 response = urlopen(self._request,
---> 48 timeout=options.get('URLOPEN_TIMEOUT'))
49 LOGGER.debug('Request headers:\n%s', self._request.header_items())
/opt/conda/lib/python3.7/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
/opt/conda/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532
/opt/conda/lib/python3.7/urllib/request.py in http_response(self, request, response)
640 response = self.parent.error(
--> 641 'http', request, response, code, msg, hdrs)
642
/opt/conda/lib/python3.7/urllib/request.py in error(self, proto, *args)
562 args = (dict, proto, meth_name) + args
--> 563 result = self._call_chain(*args)
564 if result:
/opt/conda/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
/opt/conda/lib/python3.7/urllib/request.py in http_error_302(self, req, fp, code, msg, headers)
754
--> 755 return self.parent.open(new, timeout=req.timeout)
756
/opt/conda/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532
/opt/conda/lib/python3.7/urllib/request.py in http_response(self, request, response)
640 response = self.parent.error(
--> 641 'http', request, response, code, msg, hdrs)
642
/opt/conda/lib/python3.7/urllib/request.py in error(self, proto, *args)
568 args = (dict, 'default', 'http_error_default') + orig_args
--> 569 return self._call_chain(*args)
570
/opt/conda/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
/opt/conda/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
648 def http_error_default(self, req, fp, code, msg, hdrs):
--> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)
650
HTTPError: HTTP Error 429: Too Many Requests
During handling of the above exception, another exception occurred:
ISBNLibHTTPError Traceback (most recent call last)
<ipython-input-3-ea910c25b2b6> in <module>
----> 1 isbnlib.isbn_from_words('Kafka The Definitive Guide')
/opt/conda/lib/python3.7/site-packages/isbnlib/_ext.py in isbn_from_words(words)
42 def isbn_from_words(words):
43 """Return the most probable ISBN from a list of words."""
---> 44 return goos(words)
45
46
/opt/conda/lib/python3.7/site-packages/isbnlib/dev/_decorators.py in memoized_func(*args, **kwargs)
22 return cch[key]
23 else:
---> 24 value = func(*args, **kwargs)
25 if value:
26 cch[key] = value
/opt/conda/lib/python3.7/site-packages/isbnlib/_gwords.py in goos(words)
28 appheaders={
29 'Content-Type': 'text/plain; charset="UTF-8"',
---> 30 'Content-Transfer-Encoding': 'Quoted-Printable',
31 },
32 )
/opt/conda/lib/python3.7/site-packages/isbnlib/dev/webservice.py in query(url, user_agent, values, appheaders)
83 values=values,
84 appheaders=appheaders)
---> 85 data = service.data()
86 LOGGER.debug('Raw data from service:\n%s', data)
87 return data
/opt/conda/lib/python3.7/site-packages/isbnlib/dev/webservice.py in data(self)
66 def data(self):
67 """Return the uncompressed data."""
---> 68 res = self.response()
69 LOGGER.debug('Response headers:\n%s', res.info())
70 if res.info().get('Content-Encoding') == 'gzip':
/opt/conda/lib/python3.7/site-packages/isbnlib/dev/webservice.py in response(self)
53 if e.code in (401, 403, 429):
54 raise ISBNLibHTTPError('%s Are you making many requests?' %
---> 55 e.code)
56 if e.code in (502, 504):
57 raise ISBNLibHTTPError('%s Service temporarily unavailable!' %
ISBNLibHTTPError: an HTTP error has ocurred (429 Are you making many requests?)
That is strange! What script are you using to call isbnlib
?
isbnlib.isbn_from_words('Kafka The Definitive Guide')
While calling the above after import isbnlib
Very strange.
All I can say is that Google is sending a 429 code
to your request, so in some way you (or your system) are repeating requests! How? I don't know.
Are you using the python prompt?
I was using a jupyter notebook. Should trying in a different machine with sleep
help?
Something is wrong with the Jupyter installation on that system! And has nothing to do with isbnlib
.