From 54203faddca24a52406e0fdacec86b760feee3b7 Mon Sep 17 00:00:00 2001 From: Wainer Vandelli <wainer.vandelli@cern.ch> Date: Mon, 7 Nov 2022 10:53:07 +0100 Subject: [PATCH] Update the copy thread main loop --- Script/cs/Threads/CopyThread.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Script/cs/Threads/CopyThread.py b/Script/cs/Threads/CopyThread.py index 9a77f39..720f573 100644 --- a/Script/cs/Threads/CopyThread.py +++ b/Script/cs/Threads/CopyThread.py @@ -65,10 +65,21 @@ class CopyThread(threading.Thread): self.logger.info(thread_id_string()) while not self.exitevent.is_set(): - self.startTransfers() + start_t = time() self.checkTransfers() + self.startTransfers() + + work_time_s = (time() - start_t) + # Make sure the sleep time is positive + sleep_time = max(self.conf.CopyThreadEventTimeout - work_time_s, 0) + + if sleep_time == 0: + self.logger.debug("Abnormal CopyThread cycle: "\ + "duration %s s > timeout %s s", + work_time_s, + self.conf.CopyThreadEventTimeout) - self.exitevent.wait(self.conf.CopyThreadEventTimeout) + self.exitevent.wait(sleep_time) self.logger.info('CopyThread stopping') while self.nbtransfers != 0: -- GitLab