tgherzog / wbgapi

Python module that makes using the World Bank's API a lot easier and more intuitive.
MIT License
140 stars 31 forks source link

Closes #11 #20

Closed mo-cmyk closed 2 years ago

mo-cmyk commented 2 years ago

This pull request closes issue #11 retry mechanism by retrying certain requests retries_on_failure = 5 times until aborting the request. Instead of the current implementation where the data fetching randomly quits the program.

@tgherzog Would be great if you could take a look at it.

tgherzog commented 2 years ago

The trouble is that API failures can occur for any number of reasons, some server-side and others on the user-side. For instance: if the user requests a DataFrame consisting of 100,000,000 data points, the server might just stop processing, and an "automatic" retry would simply over-burden the system. My suggestion to implement an exception handler outside the module was meant to suggest that users are best suited to determine why a session might be failing and address it according to the context, which I think is a better approach.

mo-cmyk commented 2 years ago

Hi, I wanted to implement the requested feature by complying with your provided code snippet: https://stackoverflow.com/questions/567622/is-there-a-pythonic-way-to-try-something-up-to-a-maximum-number-of-times. I also agree, but since you said it to be random I thought it to be the right approach.