Skip to content

Commit

Permalink
on_stop handler for closing ssh_sender object added
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Otepka committed Jul 4, 2024
1 parent c901aa5 commit b6dcf8a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ipyparallel/cluster/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,13 @@ def ssh_sender(self):
)
return self._ssh_sender

def _ssh_sender_stopped(self, data):
if self._ssh_sender:
self.log.info("Closing SSHLauncher::ssh_sender object")
self.ssh_sender.close()
else:
self.log.warning("SSHLauncher::ssh_sender was never initialized")

def _reconstruct_process(self, d):
# called in from_dict
# override from LocalProcessLauncher which invokes psutil.Process
Expand Down Expand Up @@ -1312,6 +1319,7 @@ def start(self, hostname=None, user=None, port=None):
self.log.info(
f"ssh sender object initiated (break_away_support={self.ssh_sender.breakaway_support})"
)
self.on_stop(self._ssh_sender_stopped)

# create remote profile dir
self.ssh_sender.check_output_python_module(
Expand All @@ -1325,7 +1333,7 @@ def start(self, hostname=None, user=None, port=None):
)
if self.log:
remote_cmd = ' '.join(self.program + self.program_args)
self.log.info(f"Running `{remote_cmd}`")
self.log.info(f"Running `{remote_cmd}` (pid={self.pid})")
# self.log.debug("Running script via ssh:\n%s", input_script)
pass
self.notify_start({'host': self.location, 'pid': self.pid})
Expand Down

0 comments on commit b6dcf8a

Please sign in to comment.