benchling_sdk.helpers.retry_helpers module¶

class RetryStrategy¶

Bases: object

Specify a strategy for automatically retrying failed HTTP calls.

__init__(max_tries: typing.Optional[int] = 5, backoff_factor: float = 1.0, status_codes_to_retry: typing.Tuple[http.HTTPStatus, ...] = (<HTTPStatus.TOO_MANY_REQUESTS: 429>, <HTTPStatus.BAD_GATEWAY: 502>, <HTTPStatus.SERVICE_UNAVAILABLE: 503>, <HTTPStatus.GATEWAY_TIMEOUT: 504>)) → None¶
backoff_factor: float = 1.0¶
max_tries: Optional[int] = 5¶
static no_retries() → RetryStrategy¶

Construct a noop retry strategy that will not retry.

status_codes_to_retry: Tuple[HTTPStatus, ...] = (<HTTPStatus.TOO_MANY_REQUESTS: 429>, <HTTPStatus.BAD_GATEWAY: 502>, <HTTPStatus.SERVICE_UNAVAILABLE: 503>, <HTTPStatus.GATEWAY_TIMEOUT: 504>)¶

Decorate a function to retry wrapped method if a BenchlingError is raised.

The wrapped method must be a method on a subclass of BaseService, because the default retry strategy is taken from the self argument of the method.

The decorator also adds an additional kwarg retry_strategy to the method signature. This can be used to override the service’s default retry strategy.