closeio / closeio-api

Python API Client for Close
http://developer.close.com/
MIT License
65 stars 47 forks source link

retry logic is broken #50

Closed charleschen closed 8 years ago

charleschen commented 8 years ago

dispatch function breaks when number of retries is greater than self.max_retries:

    def dispatch(self, method_name, endpoint, data=None):
        method = getattr(self.requests, method_name)

        retries = 0
        while True and retries < self.max_retries:
            try:
            response = method(...)
                break
            except requests.exceptions.ConnectionError:
                time.sleep(2)
                retries += 1

        if self.async:
            return response
        else:
            if response.ok:
                return response.json()
            else:
                raise APIError(response.text)

since there's ConnectionError, response is never defined.

charleschen commented 8 years ago

submitted pull-request: https://github.com/closeio/closeio-api/pull/51

charleschen commented 8 years ago

merged