UI refresh fix; added debug messages

Sat, 27 Jan 2018 12:19:39 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 27 Jan 2018 12:19:39 +0000
changeset 75
2a44b9649212
parent 74
4f56142e7497
child 76
4b08fca3ce34

UI refresh fix; added debug messages

repository.py file | annotate | diff | comparison | revisions
scheduler.py file | annotate | diff | comparison | revisions
ui.py file | annotate | diff | comparison | revisions
--- a/repository.py	Fri Jan 26 19:04:04 2018 +0000
+++ b/repository.py	Sat Jan 27 12:19:39 2018 +0000
@@ -129,7 +129,8 @@
         return self.__passphrase
 
     def launch_borg_instance(self, inst):
-        passphrase=self.__extract_passphrase()
+        with self._cond:
+            passphrase=self.__extract_passphrase()
         inst.launch(passphrase=passphrase)
 
 def find_repository(name):
--- a/scheduler.py	Fri Jan 26 19:04:04 2018 +0000
+++ b/scheduler.py	Sat Jan 27 12:19:39 2018 +0000
@@ -73,11 +73,14 @@
 
     def _insert(self, ev):
         if not self._list:
+            #logger.debug("Insert first")
             self._list=ev
         elif ev<self._list:
+            #logger.debug("Insert beginning")
             self._list.insert_immediately_before(ev)
             self._list=ev
         else:
+            #logger.debug("Insert after")
             self._list.insert_after(ev)
 
         self._cond.notify()
@@ -98,6 +101,7 @@
         super().__init__(target = self._scheduler_thread, name = 'Scheduler')
 
     def _scheduler_thread(self):
+        logger.debug("Scheduler thread started")
         with self._cond:
             while not self._terminate:
                 now = time.monotonic()
@@ -109,9 +113,12 @@
                     timeout=min(self.precision, self._list.when-now)
 
                 if not timeout or timeout>0:
+                    logger.debug("Scheduler waiting %d seconds" % (timeout or (-1)))
                     self._cond.wait(timeout)
                     now = time.monotonic()
 
+                logger.debug("Scheduler timed out")
+
                 while self._list and self._list.when <= now:
                     ev=self._list
                     logger.debug("Scheduler activating %s" % (ev.name or "(unknown)"))
@@ -136,5 +143,6 @@
 
     # cond has to be acquired on entry!
     def wait_until(self, when, cond, name=None):
+        logger.debug("Scheduling '%s' at %d" % (name, when))
         self._wait(ScheduledEvent(when, cond, name))
 
--- a/ui.py	Fri Jan 26 19:04:04 2018 +0000
+++ b/ui.py	Sat Jan 27 12:19:39 2018 +0000
@@ -240,11 +240,13 @@
             self.title=title
 
     def __status_callback(self, index, status, errorlog=None):
-        logger.debug('Status callback: %s' % str(status))
-
+        logger.debug("Tray status callback")
         with self.lock:
             self.statuses[index]=status
-            if self.refresh_timer==None and not self.refresh_timer_time:
+            # Time the refresh if it has not been timed, or if the timer
+            # is timing for the "long-term" (refresh_timer_time set)
+            if not self.refresh_timer or self.refresh_timer_time:
+                logger.debug("Timing refresh")
                 self.refresh_timer=Timer(refresh_interval, self.refresh_ui)
                 # refresh_timer_time is only set for "long-term timers"
                 self.refresh_timer_time=None

mercurial