Skip to content

Commit

Permalink
Alwats force a new connection with each request
Browse files Browse the repository at this point in the history
  • Loading branch information
MehmedGIT committed Aug 28, 2024
1 parent e0a41fb commit 3f3e0da
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/utils/operandi_utils/hpc/nhr_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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):
Expand Down
13 changes: 10 additions & 3 deletions src/utils/operandi_utils/hpc/nhr_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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,
Expand Down

0 comments on commit 3f3e0da

Please sign in to comment.