{"action":"opened","issue":{"url":"https://api.github.com/repos/googlemaps/google-maps-services-python/issues/130","repository_url":"https://api.github.com/repos/googlemaps/google-maps-services-python","labels_url":"https://api.github.com/repos/googlemaps/google-maps-services-python/issues/130/labels{/name}","comments_url":"https://api.github.com/repos/googlemaps/google-maps-services-python/issues/130/comments","events_url":"https://api.github.com/repos/googlemaps/google-maps-services-python/issues/130/events","html_url":"https://github.com/googlemaps/google-maps-services-python/issues/130","id":158515146,"number":130,"title":"In geocoding when the api status code is OVER_QUERY_LIMIT, we should raise an exception instead of retrying","user":{"login":"bmamouri","id":6419173,"avatar_url":"https://avatars.githubusercontent.com/u/6419173?v=3","gravatar_id":"","url":"https://api.github.com/users/bmamouri","html_url":"https://github.com/bmamouri","followers_url":"https://api.github.com/users/bmamouri/followers","following_url":"https://api.github.com/users/bmamouri/following{/other_user}","gists_url":"https://api.github.com/users/bmamouri/gists{/gist_id}","starred_url":"https://api.github.com/users/bmamouri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmamouri/subscriptions","organizations_url":"https://api.github.com/users/bmamouri/orgs","repos_url":"https://api.github.com/users/bmamouri/repos","events_url":"https://api.github.com/users/bmamouri/events{/privacy}","received_events_url":"https://api.github.com/users/bmamouri/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-04T17:35:58Z","updated_at":"2016-06-04T17:35:58Z","closed_at":null,"body":"When Google Maps API response with OVER_QUERY_LIMIT status code, we should raise an exception instead of retrying. According to Google Maps docs, OVER_QUERY_LIMIT is an indicator that the user is out of quota. This quota is set on API manager and is daily based.\r\n\r\nThis is the relevant code:\r\n\r\n```\r\n        try:\r\n            if extract_body:\r\n                result = extract_body(resp)\r\n            else:\r\n                result = self._get_body(resp)\r\n            self.sent_times.append(time.time())\r\n            return result\r\n        except googlemaps.exceptions._RetriableRequest:\r\n            # Retry request.\r\n            return self._get(url, params, first_request_time, retry_counter + 1,\r\n                             base_url, accepts_clientid, extract_body)\r\n\r\n    def _get_body(self, resp):\r\n        ...\r\n        if api_status == \"OVER_QUERY_LIMIT\":\r\n            raise googlemaps.exceptions._RetriableRequest()\r\n```\r\n\r\n\r\nWhat is happening here is that when API response with OVER_QUERY_LIMIT, we repeat the request until we raise `googlemaps.exceptions.Timeout` exception. This exception is misguiding as the real reason for failing in receiving the data is lack of quota not HTTP timeout.\r\n\r\nI think we need to use one of the following approaches:\r\n\r\n- If the API response code is `OVER_QUERY_LIMIT` we should just raise an appropriate exception.\r\n- Or alternatively we can retry until we exahust the `retry_counter` and eventually raise an appopriate exception."}}
{"actor":{"display_login":"bmamouri"}}