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 diff --git a/python/hopsworks/connection.py b/python/hopsworks/connection.py index 02fa7c250..1fe984030 100644 --- a/python/hopsworks/connection.py +++ b/python/hopsworks/connection.py @@ -239,6 +239,7 @@ def connect(self): conn.connect() ``` """ + client.stop() self._connected = True try: # init client