diff --git a/Script/cs/Threads/CopyThread.py b/Script/cs/Threads/CopyThread.py index 9a77f39ea4c5cb484b883ee08735ca195fa6c737..720f573146c8531a9e1c7a4026dace116f8f14a5 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: