Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding 'methodconfig' for all services in channel to allow retry #3343

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/3343.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: Adding 'methodconfig' for all services in channel to allow retry
21 changes: 21 additions & 0 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from functools import wraps
import glob
import io
import json
import os
import pathlib
import re
Expand Down Expand Up @@ -117,6 +118,25 @@

SESSION_ID_NAME = "__PYMAPDL_SESSION_ID__"

# Retry policy for gRPC calls.
SERVICE_DEFAULT_CONFIG = {
# see https://github.com/grpc/proposal/blob/master/A6-client-retries.md#retry-policy-capabilities
"methodConfig": [
{
# Match all packages and services.
# Otherwise: "name": [{"service": "<package>.<service>"}],
"name": [{}],
"retryPolicy": {
"maxAttempts": 5,
"initialBackoff": "0.01s",
"maxBackoff": "3s",
"backoffMultiplier": 3,
"retryableStatusCodes": ["UNAVAILABLE", "RESOURCE_EXHAUSTED"],
},
}
]
}


def chunk_raw(raw, save_as):
with io.BytesIO(raw) as f:
Expand Down Expand Up @@ -490,6 +510,7 @@ def _create_channel(self, ip: str, port: int) -> grpc.Channel:
channel_str,
options=[
("grpc.max_receive_message_length", MAX_MESSAGE_LENGTH),
("grpc.service_config", json.dumps(SERVICE_DEFAULT_CONFIG)),
],
)

Expand Down
Loading