Skip to content

Commit db1671d

Browse files
More checks for skipped files on visit end time (#672)
* More logs on dormancy check * Only skip files on completion if already skipped --------- Co-authored-by: Eu Pin Tien <[email protected]>
1 parent fb0f4e3 commit db1671d

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/murfey/client/multigrid_control.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,20 @@ def is_ready_for_dormancy(self):
137137
for w in self._environment.watchers.values():
138138
if w.is_safe_to_stop():
139139
w.stop()
140-
return (
141-
all(r._finalised for r in self.rsync_processes.values())
142-
and not any(a.thread.is_alive() for a in self.analysers.values())
143-
and not any(
144-
w.thread.is_alive() for w in self._environment.watchers.values()
145-
)
140+
rsyncers_finalised = all(
141+
r._finalised for r in self.rsync_processes.values()
142+
)
143+
analysers_alive = any(a.thread.is_alive() for a in self.analysers.values())
144+
watchers_alive = any(
145+
w.thread.is_alive() for w in self._environment.watchers.values()
146+
)
147+
log.debug(
148+
"Dormancy check: \n"
149+
f" rsyncers: {rsyncers_finalised} \n"
150+
f" analysers: {not analysers_alive} \n"
151+
f" watchers: {not watchers_alive}"
146152
)
153+
return rsyncers_finalised and not analysers_alive and not watchers_alive
147154
log.debug(f"Multigrid watcher for session {self.session_id} is still active")
148155
return False
149156

src/murfey/client/rsync.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def __init__(
7979
self._notify = notify
8080
self._finalised = False
8181
self._end_time = end_time
82+
self._finalising = False
8283

8384
self._skipped_files: List[Path] = []
8485

@@ -185,7 +186,7 @@ def stop(self):
185186
if self.thread.is_alive():
186187
self.queue.put(None)
187188
self.thread.join()
188-
logger.debug("RSync thread stop completed")
189+
logger.debug("RSync thread successfully stopped")
189190

190191
def request_stop(self):
191192
self._stopping = True
@@ -199,7 +200,8 @@ def finalise(
199200
self.stop()
200201
self._remove_files = True
201202
self._notify = False
202-
self._end_time = datetime.now()
203+
self._end_time = None
204+
self._finalising = True
203205
if thread:
204206
self.thread = threading.Thread(
205207
name=f"RSync finalisation {self._basepath}:{self._remote}",
@@ -284,7 +286,6 @@ def _process(self):
284286
continue
285287

286288
self._stop_callback(self._basepath, explicit_stop=self._stopping)
287-
logger.info("RSync thread finished")
288289

289290
def _fake_transfer(self, files: list[Path]) -> bool:
290291
previously_transferred = self._files_transferred
@@ -330,6 +331,9 @@ def _transfer(self, infiles: list[Path]) -> bool:
330331
]
331332
self._skipped_files.extend(set(infiles).difference(set(files)))
332333
num_skipped_files = len(set(infiles).difference(set(files)))
334+
elif self._finalising:
335+
files = [f for f in infiles if f.is_file() and f not in self._skipped_files]
336+
num_skipped_files = 0
333337
else:
334338
files = [f for f in infiles if f.is_file()]
335339
num_skipped_files = 0

0 commit comments

Comments
 (0)