Changed retry timing to start form end of previous attempt instead of beginning

Fri, 26 Jan 2018 10:31:08 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Fri, 26 Jan 2018 10:31:08 +0000
changeset 71
a8a5ebb64e02
parent 70
3f794760d52e
child 72
e0e6043779e2

Changed retry timing to start form end of previous attempt instead of beginning

backup.py file | annotate | diff | comparison | revisions
--- a/backup.py	Fri Jan 26 10:23:38 2018 +0000
+++ b/backup.py	Fri Jan 26 10:31:08 2018 +0000
@@ -191,6 +191,7 @@
         self.current_operation=None
         self.scheduled_operation=None
         self.lastrun_when=None
+        self.lastrun_finished=None
         self.state=State.INACTIVE
         self.errors=Errors.OK
 
@@ -261,7 +262,7 @@
                     msg['name']='borg'
                 lvl=translate_loglevel(msg['levelname'])
                 self.logger.log(lvl, msg['name'] + ': ' + msg['message'])
-                if lvl>=logging.ERROR
+                if lvl>=logging.ERROR:
                     errormsg=msg
                     errors=Errors.ERRORS
                     if ('msgid' in msg and
@@ -385,6 +386,7 @@
 
         if self.current_operation.operation=='create':
             self.lastrun_when=self.current_operation.when_monotonic
+            self.lastrun_finished=time.monotonic()
         self.thread_res=None
         self.thread_log=None
         self.borg_instance=None
@@ -474,7 +476,7 @@
     def __next_operation_unlocked(self):
         # TODO: pruning as well
         now=time.monotonic()
-        if not self.lastrun_when:
+        if not self.lastrun_finished:
             initial_interval=self.retry_interval
             if initial_interval==0:
                 initial_interval=self.backup_interval
@@ -488,7 +490,7 @@
                 return None
             else:
                 return Operation(Operation.CREATE,
-                                 self.lastrun_when+self.retry_interval,
+                                 self.lastrun_finished+self.retry_interval,
                                  reason='retry')
         else:
             if self.backup_interval==0:

mercurial