vayu.common¶
common
¶
retry
¶
retry(
exception_to_check: Union[_ExcType, Tuple[_ExcType]],
tries: int = 4,
delay: float = 1,
backoff: float = 2,
logger: Logger = None,
)
Retry calling the decorated function using an exponential backoff. Asyncio compatible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exception_to_check
|
Union[_ExcType, Tuple[_ExcType]]
|
the exception to check. Maybe a tuple of exceptions to check. |
required |
tries
|
int
|
number of times to try (not retry) before giving up |
4
|
delay
|
float
|
initial delay between retries in seconds |
1
|
backoff
|
float
|
backoff multiplier e.g. value of 2 will double the delay for each retry |
2
|
logger
|
Logger
|
logger to use. If None, print. |
None
|
Source code in vayu/common.py
add_jitter
¶
group
¶
Group elements of an iterable by a key function.