in ees_network_drive/utils.py [0:0]
def retry(exception_list):
"""Decorator for retrying in case of network exceptions.
Retries the wrapped method `times` times if the exceptions listed
in ``exceptions`` are thrown
:param exception_list: Lists of exceptions on which the connector should retry
"""
def decorator(func):
"""This function used as a decorator."""
def execute(self, *args, **kwargs):
"""This function execute the retry logic."""
retry = 1
while retry <= self.retry_count:
try:
return func(self, *args, **kwargs)
except exception_list as exception:
self.logger.exception(
f"Error while creating a connection. Retry count: {retry} out of {self.retry_count}. \
Error: {exception}"
)
time.sleep(2 ** retry)
retry += 1
return execute
return decorator