gigl.common.utils.retry#

Attributes#

Exceptions#

RetriesFailedException

Common base class for all non-exit exceptions.

Functions#

retry([exception_to_check, tries, delay_s, backoff, ...])

Decorator that can be added around a function to retry incase it fails i.e. throws some exceptions

Module Contents#

exception gigl.common.utils.retry.RetriesFailedException[source]#

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

gigl.common.utils.retry.retry(exception_to_check=Exception, tries=5, delay_s=3, backoff=2, max_delay_s=None, fn_execution_timeout_s=None, deadline_s=None, should_throw_original_exception=False)[source]#

Decorator that can be added around a function to retry incase it fails i.e. throws some exceptions

Parameters:
  • exception_to_check (Union[Type, Tuple[Type, ...]]) – the exception to check. Could also be a tuple of

  • everything (exceptions to check. Defaults to Exception. i.e. catches)

  • tries (Optional[int]) – [description]. number of times to try (not retry) before giving up. Defaults to 5.

  • delay_s (Optional[int]) – [description]. initial delay between retries in seconds. Defaults to 3.

  • backoff (Optional[int]) – [description]. backoff multiplier e.g. value of 2 will double the delay each retry. Defaults to 2.

  • max_delay_s (Optional[int]) – [description]. maximum delay between retries in seconds. Defaults to None.

  • fn_execution_timeout_s (Optional[int]) – Maximum time given before a single function execution should time out. Defaults to None.

  • deadline_s (Optional[int]) – [description]. Total time in seconds to spend retrying, fails if exceeds this time. Note this timeout can also stop the first execution, so ensure to provide a lot of extra room so retries can actually take place. If timeout occurs, src.common.utils.timeout.TimedOutException is raised. Defaults to None.

  • should_throw_original_exception (Optional[bool]) – Defaults to False.

Return type:

Callable[[Callable[Ellipsis, T]], Callable[Ellipsis, T]]

gigl.common.utils.retry.T[source]#
gigl.common.utils.retry.logger[source]#