DinoTools / python-overpy

Python Wrapper to access the Overpass API
https://python-overpy.readthedocs.io/
MIT License
235 stars 58 forks source link

OverpassTooManyRequests: Too many requests #56

Closed rmarzocchi84 closed 7 years ago

rmarzocchi84 commented 7 years ago
OverPy version 0.4
OS Ubuntu 14.04

Python version Python 2.7.6

I run a script which perform some query starting from data that I read from a list file. After a few request I obtain the OverpassTooManyRequests: Too many requests error.

I partially solved this problem using a sleep time which I can increase... nevertheless sometime the sleep time is not enough and my script crash.

How can avoid the crash and manage the well-known 429 error of the overpass API?

Probably I can use the exception (exception overpy.exception.OverpassTooManyRequests) ? But I do not understand how?

Teiron commented 7 years ago

OverpassTooManyRequests may occur also when Overpass servers experience heavy load. The "gentle" way to avoid it would be to increase sleep time or write custom try-catch block which would re-try connection after some time. You can also try changing the server you are querying (and on enterprise level spin your own overpass server).

Edit: BTW built-in retry may be considered as a feature worth adding.

phibos commented 7 years ago

I have added an FAQ entry about the TooManyRequests exception and I have started to implement a retry option. For more information have a look at the PR #59

phibos commented 7 years ago

I have merged the PR #59 into the master branch. OverPy should now be able to retry failed requests. You might also be interested in the OverPy FAQ