bennylope / pygeocodio

:globe_with_meridians: A Python wrapper for the Geocodio geolocation service API
BSD 3-Clause "New" or "Revised" License
94 stars 21 forks source link

Is there an option to specify timeout for requests, especially for batch geocoding? #33

Closed m01010011 closed 5 years ago

m01010011 commented 5 years ago

According to their documentation,

You can batch geocode up to 10,000 addresses at the time. Geocoding 10,000 addresses takes about 600 seconds, so please make sure to adjust your timeout value accordingly.

I checked the code for pygeocodio, but couldn't find an option to specify the time limit, especially in case we're requesting for several addresses.

The kwargs in batch_geocode(self, addresses, **kwargs) seems to be a good place for specifying the option.

bennylope commented 5 years ago

There is no option to do this currently.

However, if your concern is keeping the connection open for up to 600 seconds, I have good news - the Requests library does not apply a timeout on requests by default. In hindsight, we should probably have a timeout included on the requests from pygeocodio however in this case it means you can keep your connections open for 600 seconds... or 600,000!

A great idea for a PR would be to apply a default timeout, allow it to be overridden when initializing the client, and possibly also individual library API calls as suggested in your own comment.