[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.42-59-gc28b2f1

Andreas Beckmann debian at abeckmann.de
Sat Mar 10 09:08:54 UTC 2012


The following commit has been merged in the develop branch:
commit e4603bdb614a95de9c400d52f01dd1c139196935
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Mon Mar 5 17:57:37 2012 +0100

    use stamp files to propagate idle sections between slaves
    
    Create idle.stamp files to notify concurrent slaves about idle sections.
    Also preserves idle state over slave restarts.
    Let section sleep until the stamp file is 1 hour old.
    Ignore stamps created in the future.
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index bc99dfc..3f0cf4f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,8 @@ piuparts (0.44) UNRELEASED; urgency=low
     - Do not abort if connection to master failed, just skip the section.
     - Implement simple section locking to allow concurrent slave instances.
     - Sections wait before retry 15 minutes after error and one hour if idle.
+    - Create idle.stamp files to remember idle sections for one hour and
+      notify concurrent slaves about idle state.
   * piuparts-report.py:
     - Add link to the list of untestable logs.
     - Add more known problem reports: forgotten alternatives, warnings in
diff --git a/piuparts-slave.py b/piuparts-slave.py
index 8abb754..770020d 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -326,6 +326,15 @@ class Section:
         return ret
 
     def _run(self):
+        if os.path.exists("idle.stamp"):
+            statobj = os.stat("idle.stamp")
+            age = time.time() - statobj[stat.ST_MTIME]
+            ttl = 3600 - age
+            if age >= 0 and ttl > 0:
+                logging.info("idle")
+                self._sleep_until = time.time() + ttl
+                return 0
+
         try:
             self._slave.connect_to_master(self._log_file)
         except KeyboardInterrupt:
@@ -356,7 +365,11 @@ class Section:
 
         if not self._slave.get_reserved():
             self._sleep_until = time.time() + 3600
+            create_file("idle.stamp", "%d" % time.time())
             return 0
+        else:
+            if os.path.exists("idle.stamp"):
+                os.unlink("idle.stamp")
 
         test_count = 0
         if self._slave.get_reserved():

-- 
piuparts git repository



More information about the Piuparts-commits mailing list