Skip to content

Commit 78d5348

Browse files
committed
Fix code-quality issue in RemoteCommandExecutor
The __del__ special method is designed to be called by the Python virtual machine when an object is no longer reachable, but before it is destroyed. Calling a __del__ method explicitly may cause an object to enter an unsafe state. Signed-off-by: Nicola Sirena <[email protected]>
1 parent a9bf358 commit 78d5348

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/integration-tests/remote_command_executor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def __init__(
7474
self.__user_at_hostname = "{0}@{1}".format(username, node_ip)
7575

7676
def __del__(self):
77+
self.close_connection()
78+
79+
def close_connection(self):
80+
"""Close SSH connection."""
7781
try:
7882
self.__connection.close()
7983
except Exception as e:
@@ -82,7 +86,7 @@ def __del__(self):
8286

8387
def reset_connection(self):
8488
"""Reset SSH connection."""
85-
self.__del__()
89+
self.close_connection()
8690
if self.__connection_kwargs:
8791
self.__connection = Connection(**self.__connection_kwargs)
8892

0 commit comments

Comments
 (0)