mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Extract method for checking connection and version from python.
This commit is contained in:
parent
d1c0226fd2
commit
79b9134c40
@ -182,6 +182,28 @@ class Instance:
|
|||||||
# Main version check package
|
# Main version check package
|
||||||
self.app = App_pb2_grpc.AppStub(self.channel)
|
self.app = App_pb2_grpc.AppStub(self.channel)
|
||||||
|
|
||||||
|
self._check_connection_and_version(self.channel, launched)
|
||||||
|
|
||||||
|
# Intercept UNAVAILABLE errors and retry on failures
|
||||||
|
interceptors = (
|
||||||
|
RetryOnRpcErrorClientInterceptor(
|
||||||
|
retry_policy=ExponentialBackoffRetryPolicy(min_backoff=100, max_backoff=5000, max_num_retries=20),
|
||||||
|
status_for_retry=(grpc.StatusCode.UNAVAILABLE,),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
intercepted_channel = grpc.intercept_channel(self.channel, *interceptors)
|
||||||
|
|
||||||
|
# Recreate ommand stubs with the retry policy
|
||||||
|
self.commands = Commands_pb2_grpc.CommandsStub(intercepted_channel)
|
||||||
|
|
||||||
|
# Service packages
|
||||||
|
self.project = Project.create(intercepted_channel)
|
||||||
|
|
||||||
|
path = os.getcwd()
|
||||||
|
self.set_start_dir(path=path)
|
||||||
|
|
||||||
|
def _check_connection_and_version(self, channel, launched):
|
||||||
connection_ok = False
|
connection_ok = False
|
||||||
version_ok = False
|
version_ok = False
|
||||||
|
|
||||||
@ -206,25 +228,6 @@ class Instance:
|
|||||||
self.version_string(), " ",
|
self.version_string(), " ",
|
||||||
self.client_version_string())
|
self.client_version_string())
|
||||||
|
|
||||||
# Intercept UNAVAILABLE errors and retry on failures
|
|
||||||
interceptors = (
|
|
||||||
RetryOnRpcErrorClientInterceptor(
|
|
||||||
retry_policy=ExponentialBackoffRetryPolicy(min_backoff=100, max_backoff=5000, max_num_retries=20),
|
|
||||||
status_for_retry=(grpc.StatusCode.UNAVAILABLE,),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
intercepted_channel = grpc.intercept_channel(self.channel, *interceptors)
|
|
||||||
|
|
||||||
# Recreate ommand stubs with the retry policy
|
|
||||||
self.commands = Commands_pb2_grpc.CommandsStub(intercepted_channel)
|
|
||||||
|
|
||||||
# Service packages
|
|
||||||
self.project = Project.create(intercepted_channel)
|
|
||||||
|
|
||||||
path = os.getcwd()
|
|
||||||
self.set_start_dir(path=path)
|
|
||||||
|
|
||||||
def __version_message(self):
|
def __version_message(self):
|
||||||
return self.app.GetVersion(Empty())
|
return self.app.GetVersion(Empty())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user