[Treepkg-commits] r238 - trunk/treepkg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 2 17:31:48 CET 2009


Author: bh
Date: 2009-12-02 17:31:48 +0100 (Wed, 02 Dec 2009)
New Revision: 238

Modified:
   trunk/treepkg/packager.py
Log:
Rework the packager mainloop. it's a bit simpler now and stopping should
be more reliable.


Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py	2009-12-02 15:37:46 UTC (rev 237)
+++ trunk/treepkg/packager.py	2009-12-02 16:31:48 UTC (rev 238)
@@ -617,30 +617,29 @@
         logging.info("binary packages needed as build dependencies: %s",
                      " ".join(self.needed_binaries))
 
-
     def run(self):
         """Runs the packager group indefinitely"""
         logging.info("Starting in periodic check mode."
                      "  Will check every %d seconds", self.check_interval)
-        last_check = -1
+        next_check = time.time()
         while 1:
-            now = time.time()
-            if now > last_check + self.check_interval:
+            if self.should_stop():
+                logging.info("Received stop instruction.  Stopping.")
+                return
+
+            this_check = time.time()
+            if this_check >= next_check:
+                logging.info("Next check is now")
                 if self.check_package_tracks():
                     break
-                last_check = now
-                next_check = now + self.check_interval
-                to_sleep = next_check - time.time()
-                if to_sleep > 0:
-                    logging.info("Next check at %s",
-                                 time.strftime("%Y-%m-%d %H:%M:%S",
-                                               time.localtime(next_check)))
-                    time.sleep(to_sleep)
-                else:
-                    logging.info("Next check now")
-                if self.should_stop():
-                    logging.info("Received stop instruction.  Stopping.")
-                    return
+                last_check = this_check
+                next_check = this_check + self.check_interval
+            else:
+                to_sleep = next_check - this_check
+                logging.info("Next check at %s",
+                             time.strftime("%Y-%m-%d %H:%M:%S",
+                                           time.localtime(next_check)))
+                time.sleep(to_sleep)
 
     def check_package_tracks(self):
         logging.info("Checking package tracks")



More information about the Treepkg-commits mailing list