pyufunc.retry_on_exception#

pyufunc.retry_on_exception(function=None, *, attempts=3, wait_seconds=0, retry_exceptions=<class 'Exception'>)#

Decorate a function to retry on selected exceptions.

Parameters:
  • function – Optional function to decorate.

  • attempts – Maximum number of attempts.

  • wait_seconds – Fixed wait time between attempts.

  • retry_exceptions – Exception type or tuple of exception types to retry.

Note

Example

>>> retrying = retry_on_exception(lambda: "ok", attempts=1)
>>> retrying()
'ok'
Returns:

Decorated callable or decorator.

Return type:

Callable[…, Any]