Skip to content

Commit

Permalink
SshTransport: Add channel timeout as argument to `exec_command_wait…
Browse files Browse the repository at this point in the history
…_bytes` (#6452)
  • Loading branch information
unkcpz authored Jun 6, 2024
1 parent b1a7141 commit 7cb0068
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/aiida/transports/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ def _exec_command_internal(self, command, combine_stderr=False, bufsize=-1):

return stdin, stdout, stderr, channel

def exec_command_wait_bytes(self, command, stdin=None, combine_stderr=False, bufsize=-1):
def exec_command_wait_bytes(self, command, stdin=None, combine_stderr=False, bufsize=-1, timeout=0.01):
"""Executes the specified command and waits for it to finish.
:param command: the command to execute
Expand All @@ -1327,6 +1327,7 @@ def exec_command_wait_bytes(self, command, stdin=None, combine_stderr=False, buf
:param combine_stderr: (optional, default=False) see docstring of
self._exec_command_internal()
:param bufsize: same meaning of paramiko.
:param timeout: ssh channel timeout for stdout, stderr.
:return: a tuple with (return_value, stdout, stderr) where stdout and stderr
are both bytes and the return_value is an int.
Expand Down Expand Up @@ -1374,8 +1375,8 @@ def exec_command_wait_bytes(self, command, stdin=None, combine_stderr=False, buf
# if compression is enabled).
# It's important to mention that, for speed benchmarks, it's important to disable compression
# in the SSH transport settings, as it will cap the max speed.
stdout.channel.settimeout(0.01)
stderr.channel.settimeout(0.01) # Maybe redundant, as this could be the same channel.
stdout.channel.settimeout(timeout)
stderr.channel.settimeout(timeout) # Maybe redundant, as this could be the same channel.

while True:
chunk_exists = False
Expand Down

0 comments on commit 7cb0068

Please sign in to comment.