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: Raise an exception if license is inaccessible #3316

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
15 changes: 15 additions & 0 deletions src/ansys/fluent/core/launcher/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
from ansys.fluent.core.utils.fluent_version import FluentVersion


class InaccessibleAnsysLicense(RuntimeError):
"""Raised when license is inaccessible."""

def __init__(self):
super().__init__("Ansys license is inaccessible.")


def _license_error(exception):
exception_msg = "IOCP/Socket: Connection reset (An existing connection was forcibly closed by the remote host.\r\n -- 10054)"
if type(exception) == RuntimeError and exception.args[0] == exception_msg:
raise InaccessibleAnsysLicense()
else:
return False


class InvalidPassword(ValueError):
"""Raised when password is invalid."""

Expand Down
4 changes: 3 additions & 1 deletion src/ansys/fluent/core/services/interceptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from google.protobuf.message import Message
import grpc

from ansys.fluent.core.launcher.error_handler import _license_error
from ansys.fluent.core.services.batch_ops import BatchOps

network_logger: logging.Logger = logging.getLogger("pyfluent.networking")
Expand Down Expand Up @@ -109,7 +110,8 @@ def _intercept_call(
grpc_ex = response.exception()
ex = RuntimeError(grpc_ex.details())
ex.__context__ = grpc_ex
raise ex from None
if not _license_error(ex):
raise ex from None
hpohekar marked this conversation as resolved.
Show resolved Hide resolved
return response

def intercept_unary_unary(
Expand Down