diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 9c23ab45e..c160b6458 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -88,6 +88,14 @@ class ApiRequest(object): try: return json.loads(response) except ValueError: return response + def retry(self, n): + """Try to send request n times. If after n times it fails then + we finally raise exception""" + for i in range(0,n-1): + try: return self() + except Exception: pass + return self() + class RequestProvider(object): """ Creates the available ApiRequest instance that can be read from a config file """