Fixed retry scheduling

Sat, 20 Jan 2018 20:34:32 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 20 Jan 2018 20:34:32 +0000
changeset 12
16a8c63344c0
parent 11
0bff53095f28
child 13
1813654427d7

Fixed retry scheduling

backup.py file | annotate | diff | comparison | revisions
instance.py file | annotate | diff | comparison | revisions
--- a/backup.py	Sat Jan 20 20:34:23 2018 +0000
+++ b/backup.py	Sat Jan 20 20:34:32 2018 +0000
@@ -141,11 +141,6 @@
 
         logging.debug('Borg subprocess terminated; terminating log listener thread')
 
-        with self.lock:
-            self.thread_log=None
-            self.__finish_and_reschedule_if_both_listeners_terminated()
-
-
     def __result_listener(self):
         with self.lock:
             status, callback=self.__status_unlocked()
@@ -169,23 +164,21 @@
 
         logging.debug('Borg subprocess terminated (success: %s); terminating result listener thread' % str(success))
 
+        self.thread_log.join()
+
         with self.lock:
             if self.current_operation['operation']=='create':
                 self.lastrun=self.current_operation['when_monotonic']
                 self.lastrun_success=success
             self.thread_res=None
-            self.__finish_and_reschedule_if_both_listeners_terminated()
+            self.thread_log=None
+            self.borg_instance=None
+            self.current_operation=None
+            self.__schedule_unlocked()
             status, callback=self.__status_unlocked()
         if callback:
             callback(self, status)
 
-    def __finish_and_reschedule_if_both_listeners_terminated(self):
-        if self.thread_res==None and self.thread_log==None:
-            logging.debug('Both threads terminated')
-            self.borg_instance=None
-            self.current_operation=None
-            self.__schedule_unlocked()
-
     def __do_launch(self, queue, op, archive_or_repository, *args):
         inst=BorgInstance(op['operation'], archive_or_repository, *args)
         inst.launch()
--- a/instance.py	Sat Jan 20 20:34:23 2018 +0000
+++ b/instance.py	Sat Jan 20 20:34:32 2018 +0000
@@ -40,7 +40,10 @@
 
         logging.info('Launching ' + str(cmd))
 
-        self.proc=Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=None)
+        self.proc=Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)
+
+        # We don't do password input etc.
+        self.proc.stdin.close()
 
     def read_result(self):
         stream=self.proc.stdout

mercurial