The V2.0 software development kit (SDK) includes a built-in automatic retry mechanism for network exceptions that occur during OpenAPI request processing. If a request fails because of a network issue, the system automatically retries the request to improve service stability and reliability. However, the SDK does not retry requests that fail because of business logic errors, such as invalid parameters or a resource that does not exist. Your application must handle these errors based on the specific error message instead of retrying the request. This topic describes how to configure the automatic retry mechanism for network exceptions in the V2.0 SDK.
Configuration methods
Configuration priority: RuntimeOptions settings take precedence over the default configurations.
Use the default configurations. By default, requests are not retried. If you enable retries but do not specify the number of retries, the system retries the request up to three times.
Configure the retry mechanism using runtime parameters (RuntimeOptions).
from alibabacloud_tea_util.models import RuntimeOptions runtimeOptions = RuntimeOptions( autoretry=True, # Specifies whether to enable retries. Retries are disabled by default. max_attempts=3 # The number of maximum retry attempts. The default value is 3. )