Utilities
- class yadisk.utils.CaseInsensitiveDict(*args, **kwargs)[source]
A case-insensitive dictionary. All keys are converted to lowercase.
- get(key: str, /, *args, **kwargs) Any[source]
Return the value for key if key is in the dictionary, else default.
- pop(k[, d]) v, remove specified key and return the corresponding value.[source]
If the key is not found, return the default if given; otherwise, raise a KeyError.
- async yadisk.utils.async_auto_retry(func: Callable[[...], Any] | Callable[[...], Awaitable[Any]], n_retries: int | None = None, retry_interval: int | float | None = None, args: tuple | None = None, kwargs: dict[str, Any] | None = None, retry_on: tuple[type[Exception], ...] = ()) Any[source]
Attempt to perform a request with automatic retries. A retry is triggered by
RequestErrororRetriableYaDiskError, unless the raised exception hasdisable_retryset toTrue.- Parameters:
func – function to run, must not require any arguments
n_retries – int, maximum number of retries
retry_interval – int or float, delay between retries (in seconds)
args – tuple or None, additional arguments for func
kwargs – dict or None, additional keyword arguments for func
retry_on – tuple, additional exception classes to retry on
- Returns:
return value of func()
- yadisk.utils.auto_retry(func: Callable[[...], T], n_retries: int | None = None, retry_interval: int | float | None = None, args: tuple | None = None, kwargs: dict[str, Any] | None = None, retry_on: tuple[type[Exception], ...] = ()) T[source]
Attempt to perform a request with automatic retries. A retry is triggered by
RequestErrororRetriableYaDiskError, unless the raised exception hasdisable_retryset toTrue.- Parameters:
func – function to run, must not require any arguments
n_retries – int, maximum number of retries
retry_interval – int or float, delay between retries (in seconds)
args – tuple or None, additional arguments for func
kwargs – dict or None, additional keyword arguments for func
retry_on – tuple, additional exception classes to retry on
- Returns:
return value of func()
- yadisk.utils.get_exception(response: Response | AsyncResponse, error: ErrorObject | None) YaDiskError[source]
Get an exception instance based on response, assuming the request has failed.
- Parameters:
response – an instance of
ResponseorAsyncResponseerror – an instance of
ErrorObjector None
- Returns:
an exception instance, subclass of
YaDiskError