SuLab / WikidataIntegrator

A Wikidata Python module integrating the MediaWiki API and the Wikidata SPARQL endpoint
MIT License
244 stars 46 forks source link

Exception upon 429 response code #195

Closed oripka closed 2 years ago

oripka commented 2 years ago

The variable retry_after is not converted into a number before passing it into the sleep() function. This causes an error when a 429 response code with the retry-after header is received. time.sleep(int(retry_after)) might be enough to deal with this.

[/usr/local/lib/python3.7/dist-packages/wikidataintegrator/wdi_core.py](https://localhost:8080/#) in execute_sparql_query(query, prefix, endpoint, user_agent, as_dataframe, max_retries, retry_after)
    131                     retry_after = response.headers["retry-after"]
    132                 print("service unavailable. sleeping for {} seconds".format(retry_after))
--> 133                 time.sleep(retry_after)
    134                 continue
    135             response.raise_for_status()

TypeError: an integer is required (got type str)