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

Set Server live attribute before super().__init__ #1293

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 24 additions & 18 deletions src/ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,15 +673,20 @@ def __init__(
# Load DPFClientAPI
from ansys.dpf.core.misc import is_pypim_configured

super().__init__(ansys_path=ansys_path, load_operators=load_operators)
# Load Ans.Dpf.GrpcClient
self._grpc_client_path = load_api.load_grpc_client(ansys_path=ansys_path)
self._own_process = launch_server
self._local_server = False
self._os = None
self._version = None

super().__init__(ansys_path=ansys_path, load_operators=load_operators)
# Load Ans.Dpf.GrpcClient
self._grpc_client_path = load_api.load_grpc_client(ansys_path=ansys_path)

address = f"{ip}:{port}"
# store port and ip for later reference
self._address = address
self._input_ip = ip
self._input_port = port

self._remote_instance = None
if launch_server:
Expand All @@ -695,6 +700,9 @@ def __init__(
address = self._remote_instance.services["grpc"].uri
ip = address.split(":")[-2]
port = int(address.split(":")[-1])
self._address = address
self._input_ip = ip
self._input_port = port

elif docker_config.use_docker:
self.docker_config = server_factory.RunningDockerConfig(docker_config)
Expand All @@ -709,12 +717,8 @@ def __init__(
launch_dpf(ansys_path, ip, port, timeout=timeout)
self._local_server = True

self._client = GrpcClient(address)
# store port and ip for later reference
self._address = address
self._input_ip = ip
self._input_port = port
self.live = True
self._client = GrpcClient(address)
self._create_shutdown_funcs()
self._check_first_call(num_connection_tryouts)
try:
Expand Down Expand Up @@ -1005,13 +1009,13 @@ def __init__(
# Use ansys.grpc.dpf
from ansys.dpf.core.misc import is_pypim_configured

super().__init__()

self._info_instance = None
self._own_process = launch_server
self.live = False
self._local_server = False

super().__init__()

# Load Ans.Dpf.Grpc?
import grpc

Expand All @@ -1021,6 +1025,12 @@ def __init__(
raise ValueError("Port must be an integer")

address = f"{ip}:{port}"
# store the address for later reference
self._address = address
self._input_ip = ip
self._input_port = port
self.ansys_path = ansys_path
self._stubs = {}

self._remote_instance = None
if launch_server:
Expand All @@ -1032,8 +1042,11 @@ def __init__(
):
self._remote_instance = launch_remote_dpf()
address = self._remote_instance.services["grpc"].uri
self._address = address
ip = address.split(":")[-2]
port = int(address.split(":")[-1])
self._input_ip = ip
self._input_port = port
else:

if docker_config.use_docker:
Expand All @@ -1048,17 +1061,10 @@ def __init__(
else:
launch_dpf(ansys_path, ip, port, timeout=timeout)
self._local_server = True
self.live = True

self.channel = grpc.insecure_channel(address)

# store the address for later reference
self._address = address
self._input_ip = ip
self._input_port = port
self.live = True
self.ansys_path = ansys_path
self._stubs = {}

self._create_shutdown_funcs()

check_ansys_grpc_dpf_version(self, timeout)
Expand Down
Loading