From 6ad8ae08b1f85b0d8784fa5d8bed9406b424df8c Mon Sep 17 00:00:00 2001 From: Victor Jouffrey Date: Thu, 21 Mar 2024 11:59:50 +0100 Subject: [PATCH] Cleanup client irrespective of whether connection was set --- python/hopsworks/__init__.py | 5 +++-- python/hopsworks/client/__init__.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/hopsworks/__init__.py b/python/hopsworks/__init__.py index b428527a0..23dcea9df 100644 --- a/python/hopsworks/__init__.py +++ b/python/hopsworks/__init__.py @@ -23,7 +23,7 @@ from pathlib import Path from hopsworks.client.exceptions import RestAPIError, ProjectException -from hopsworks import version, constants +from hopsworks import version, constants, client from hopsworks.connection import Connection # Needs to run before import of hsml and hsfs @@ -283,6 +283,7 @@ def _prompt_project(valid_connection, project): def logout(): global _hw_connection - if type(_hw_connection) is Connection: + if isinstance(_hw_connection, Connection): _hw_connection.close() + client.stop() _hw_connection = Connection.connection diff --git a/python/hopsworks/client/__init__.py b/python/hopsworks/client/__init__.py index 3bbd3d17b..1e4a7ea8f 100644 --- a/python/hopsworks/client/__init__.py +++ b/python/hopsworks/client/__init__.py @@ -67,5 +67,6 @@ def set_python_version(python_version): def stop(): global _client - _client._close() + if _client: + _client._close() _client = None