From 906b1b3205bfc61ffae8aa3459855d7ef4519f5e Mon Sep 17 00:00:00 2001 From: swainn Date: Thu, 5 Sep 2019 14:01:22 -0600 Subject: [PATCH 1/2] Fixes issues with connections remaining open when using remote clients for running commands. --- condorpy/remote_utils.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/condorpy/remote_utils.py b/condorpy/remote_utils.py index 774877a..e446c9a 100644 --- a/condorpy/remote_utils.py +++ b/condorpy/remote_utils.py @@ -23,6 +23,9 @@ def __init__(self, self._scp = None self._sftp = None + def __del__(self): + self.close() + @property def transport(self): if self._transport is None or not self._transport.is_active(): @@ -52,13 +55,17 @@ def _get_output(self, session): return stdout, stderr def execute(self, command): - session = self.transport.open_session() - session.exec_command(command) - stdout, stderr = self._get_output(session) - exit_status = session.recv_exit_status() - if exit_status != 0: - msg = "The command '{0}' failed on host '{1}':\n{2}\n{3}".format(command, self.host, stdout, stderr) - raise RuntimeError(msg) + session = None + try: + session = self.transport.open_session() + session.exec_command(command) + stdout, stderr = self._get_output(session) + exit_status = session.recv_exit_status() + if exit_status != 0: + msg = "The command '{0}' failed on host '{1}':\n{2}\n{3}".format(command, self.host, stdout, stderr) + raise RuntimeError(msg) + finally: + session and session.close() return stdout, stderr From b29e2a98742f0ddadf47e6eaee4c54412c5b7d53 Mon Sep 17 00:00:00 2001 From: swainn Date: Thu, 5 Sep 2019 14:02:17 -0600 Subject: [PATCH 2/2] Version 0.5.2 --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index fb4abfe..b4c87b4 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ CondorPy ======== :condorpy: Python interface for high throughput computing with HTCondor -:Version: 0.5.1 +:Version: 0.5.2 :Author: Scott Christensen :Team: Tethys Platform :Homepage: http://tethysplatform.org/condorpy/