From 25ac4ff15ba80372505786d794c1626770c7c364 Mon Sep 17 00:00:00 2001 From: Daniel Hatton Date: Mon, 13 Jan 2025 15:44:29 +0000 Subject: [PATCH] Allow the avoidance of the creation of a thread inside rsyncer finalisation --- src/murfey/client/multigrid_control.py | 1 + src/murfey/client/rsync.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/murfey/client/multigrid_control.py b/src/murfey/client/multigrid_control.py index 9833f2353..2d590956b 100644 --- a/src/murfey/client/multigrid_control.py +++ b/src/murfey/client/multigrid_control.py @@ -159,6 +159,7 @@ def _finalise_rsyncer(self, source: Path): finalise_thread = threading.Thread( name=f"Controller finaliser thread ({source})", target=self.rsync_processes[source].finalise, + kwargs={"thread": False}, daemon=True, ) finalise_thread.start() diff --git a/src/murfey/client/rsync.py b/src/murfey/client/rsync.py index 80e1c99a6..74a122f56 100644 --- a/src/murfey/client/rsync.py +++ b/src/murfey/client/rsync.py @@ -172,18 +172,21 @@ def stop(self): self.thread.join() logger.debug("RSync thread stop completed") - def finalise(self): + def finalise(self, thread: bool = True): self.stop() self._remove_files = True self._notify = False - self.thread = threading.Thread( - name=f"RSync finalisation {self._basepath}:{self._remote}", - target=self._process, - daemon=True, - ) - for f in self._basepath.glob("**/*"): - self.queue.put(f) - self.stop() + if thread: + self.thread = threading.Thread( + name=f"RSync finalisation {self._basepath}:{self._remote}", + target=self._process, + daemon=True, + ) + for f in self._basepath.glob("**/*"): + self.queue.put(f) + self.stop() + else: + self._transfer(list(self._basepath.glob("**/*"))) def enqueue(self, file_path: Path): if not self._stopping: