Skip to content

Commit

Permalink
feat: Adding 'methodconfig' for all services in channel that allow to…
Browse files Browse the repository at this point in the history
… retry (#3343)

* feat: Adding 'methodconfig' for all services in channel that allow to retry

* chore: adding changelog file 3343.miscellaneous.md

---------

Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
  • Loading branch information
germa89 and pyansys-ci-bot committed Aug 27, 2024
1 parent c8fb44e commit 0c0f679
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit 0c0f679

Please sign in to comment.