diff --git a/autosubmit/autosubmit.py b/autosubmit/autosubmit.py index 6f84065b754ce16832196a06cac1733fd999f0d7..dcd94d11b51ce33a6428f421687eabf07ecbb753 100644 --- a/autosubmit/autosubmit.py +++ b/autosubmit/autosubmit.py @@ -2384,6 +2384,7 @@ class Autosubmit: if p.log_recovery_process: p.cleanup_event.set() # Send cleanup event p.log_recovery_process.join() + Log.info(f"Log recovery process for {p.name} has finished") for job in job_list.get_completed_failed_without_logs(): # update the info gathered from the childs job_list.update_log_status(job, as_conf) job_list.save() @@ -2401,8 +2402,8 @@ class Autosubmit: Autosubmit.database_fix(expid) except Exception as e: pass - for platform in platforms_to_test: - platform.closeConnection() + for p in platforms_to_test: + p.closeConnection() if len(job_list.get_failed()) > 0: Log.info("Some jobs have failed and reached maximum retrials") else: diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index 205a869ebec10d5dbffe3dfbf0434afaa6ced37e..eba3f9f953585bcc61a2f6d08f808174be1a7a9c 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -95,6 +95,7 @@ class ParamikoPlatform(Platform): return self._wrapper def reset(self): + self.closeConnection() self.connected = False self._ssh = None self._ssh_config = None diff --git a/autosubmit/platforms/platform.py b/autosubmit/platforms/platform.py index 326189c7ccecd8cac58c5c7d4f888d905fd2aa29..bbc609e7a10b1acd80cc94fc3169aa9507330388 100644 --- a/autosubmit/platforms/platform.py +++ b/autosubmit/platforms/platform.py @@ -1,6 +1,7 @@ import atexit import multiprocessing import queue # only for the exception +from os import _exit import setproctitle import locale import os @@ -882,6 +883,7 @@ class Platform(object): Log.result(f"Process {self.log_recovery_process.name} started with pid {self.log_recovery_process.pid}") # Cleanup will be automatically prompt on control + c or a normal exit atexit.register(self.send_cleanup_signal) + atexit.register(self.closeConnection) def send_cleanup_signal(self) -> None: """ @@ -992,4 +994,6 @@ class Platform(object): if self.cleanup_event.is_set(): # Check if the main process is waiting for this child to end. self.recover_job_log(identifier, jobs_pending_to_process) break + self.closeConnection() Log.info(f"{identifier} Exiting.") + _exit(0) # Exit userspace after manually closing ssh sockets, recommended for child processes, the queue() and shared signals should be in charge of the main process.