The V2.0 SDK includes a built-in automatic retry mechanism for network exceptions during OpenAPI request processing. When a request fails due to a network issue, the system automatically retries the request to improve stability and reliability. The SDK does not retry business logic errors such as invalid parameters or nonexistent resources. Your application must handle these errors based on the specific error message.
Configuration methods
Note
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. )