diff --git a/databend_py/connection.py b/databend_py/connection.py index 4d5492e..d4eedf6 100644 --- a/databend_py/connection.py +++ b/databend_py/connection.py @@ -127,7 +127,7 @@ def get_description(self): def disconnect(self): self.client_session = dict() - @retry(times=5, exceptions=WarehouseTimeoutException) + @retry(times=10, exceptions=WarehouseTimeoutException) def do_query(self, url, query_sql): response = self.requests_session.post(url, data=json.dumps(query_sql), diff --git a/databend_py/retry.py b/databend_py/retry.py index 1fb75d3..2325f9d 100644 --- a/databend_py/retry.py +++ b/databend_py/retry.py @@ -3,6 +3,7 @@ from databend_py.errors import WarehouseTimeoutException +# retry in 550s for WarehouseTimeoutException def retry(times, exceptions): """ Retry Decorator @@ -15,8 +16,8 @@ def retry(times, exceptions): def decorator(func): def newfn(*args, **kwargs): - attempt = 0 - while attempt < times: + attempt = 1 + while attempt <= times: try: return func(*args, **kwargs) except exceptions: @@ -24,7 +25,7 @@ def newfn(*args, **kwargs): 'Exception thrown when attempting to run %s, attempt ' '%d of %d' % (func, attempt, times) ) - time.sleep(attempt * 5) + time.sleep(attempt * 10) attempt += 1 return func(*args, **kwargs)