mvexel / overpass-api-python-wrapper

Python bindings for the OpenStreetMap Overpass API
Apache License 2.0
367 stars 90 forks source link

self._timeout is used in the TimeoutError exception even if it has been change in self.timeout #52

Closed sandrotosi closed 2 years ago

sandrotosi commented 8 years ago
In [27]: api = overpass.API(timeout=3)

In [28]: response = api.Get(s)
---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
<ipython-input-28-cee6cde6e022> in <module>()
----> 1 response = api.Get(s)

/usr/lib/python3/dist-packages/overpass/api.py in Get(self, query, responseformat, verbosity)
     43 
     44         # Get the response from Overpass
---> 45         raw_response = self._GetFromOverpass(full_query)
     46 
     47         if responseformat == "xml":

/usr/lib/python3/dist-packages/overpass/api.py in _GetFromOverpass(self, query)
    100 
    101         except requests.exceptions.Timeout:
--> 102             raise TimeoutError(self._timeout)
    103 
    104         self._status = r.status_code

TimeoutError: 25

that's because it uses self._timeout (always set to 25) but the API class defines the timeout as

self.timeout = kwargs.get("timeout", self._timeout)

and it's the correct value used to determine if it has timed out or not, so i think that's the value to be used in the exception as well

mvexel commented 7 years ago

I think you are right, care to supply a PR with the fix?

mvexel commented 2 years ago

Closing this for lack of activity. Feel free to re-open if this is still reproducible for you!