From 3f3e0dab548311abdfc55401832cfbb47f28ee03 Mon Sep 17 00:00:00 2001 From: Mehmed Mustafa Date: Wed, 28 Aug 2024 20:14:25 +0200 Subject: [PATCH] Alwats force a new connection with each request --- src/utils/operandi_utils/hpc/nhr_connector.py | 15 ++++++++++++--- src/utils/operandi_utils/hpc/nhr_transfer.py | 13 ++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/utils/operandi_utils/hpc/nhr_connector.py b/src/utils/operandi_utils/hpc/nhr_connector.py index bdd509f..dc7bde7 100644 --- a/src/utils/operandi_utils/hpc/nhr_connector.py +++ b/src/utils/operandi_utils/hpc/nhr_connector.py @@ -39,9 +39,13 @@ def __init__( @property def ssh_client(self): - if not self._ssh_client: - self._ssh_client = self.connect_to_hpc_nhr_frontend_server(host=HPC_NHR_CLUSTERS["EmmyPhase2"]["host"]) - self._ssh_client.get_transport().set_keepalive(30) + if self._ssh_client: + self._ssh_client.close() + self._ssh_client = None + self._ssh_client = self.connect_to_hpc_nhr_frontend_server(host=HPC_NHR_CLUSTERS["EmmyPhase2"]["host"]) + # self._ssh_client.get_transport().set_keepalive(30) + + """ try: # Note: This extra check is required against aggressive # Firewalls that ignore the keepalive option! @@ -58,6 +62,11 @@ def ssh_client(self): self._ssh_reconnect_tries_remaining -= 1 return self.ssh_client # recursive call to itself to try again return self._ssh_client + """ + + return self._ssh_client + + @staticmethod def check_keyfile_existence(key_path: Path): diff --git a/src/utils/operandi_utils/hpc/nhr_transfer.py b/src/utils/operandi_utils/hpc/nhr_transfer.py index a0a2b65..1170607 100644 --- a/src/utils/operandi_utils/hpc/nhr_transfer.py +++ b/src/utils/operandi_utils/hpc/nhr_transfer.py @@ -21,9 +21,13 @@ def __init__(self) -> None: @property def sftp_client(self): - if not self._sftp_client: - self._sftp_client = self.ssh_client.open_sftp() - self._sftp_client.get_channel().get_transport().set_keepalive(30) + if self._sftp_client: + self._sftp_client.close() + self._ssh_client = None + self._sftp_client = self.ssh_client.open_sftp() + # self._sftp_client.get_channel().get_transport().set_keepalive(30) + + """ try: # Note: This extra check is required against aggressive # Firewalls that ignore the keepalive option! @@ -40,6 +44,9 @@ def sftp_client(self): self._sftp_reconnect_tries_remaining -= 1 return self.sftp_client # recursive call to itself to try again return self._sftp_client + """ + + return self._ssh_client def create_slurm_workspace_zip( self, ocrd_workspace_dir: str, workflow_job_id: str, nextflow_script_path: str,