[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.45-74-gac51d65

Andreas Beckmann debian at abeckmann.de
Sat Jul 21 15:56:33 UTC 2012


The following commit has been merged in the develop branch:
commit 38bfe40c9da1779a816ac9e0307408595e379099
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Sat Jul 21 13:52:41 2012 +0200

    p-s: add SIGHUP handler to trigger flushing finished logs
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index afe02db..6701ccb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -30,6 +30,8 @@ piuparts (0.46) UNRELEASED; urgency=low
       precedence settings.
     - Skip connection to master if we have reserved but no submittable logs.
     - Submit finished logs after completing all reserved logs in a section.
+    - Add SIGHUP handler that triggers flushing finished logs.  Flushing (all
+      sections) will be done after the current test has finished.
   * piuparts-report.py:
   * Simplify running piuparts from GIT.
   * Reorganize layout in the GIT repository to reduce path nesting and length.
diff --git a/piuparts-slave.py b/piuparts-slave.py
index 1738a62..cda06a5 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -28,7 +28,7 @@ import sys
 import stat
 import time
 import logging
-from signal import alarm, signal, SIGALRM, SIGINT, SIGKILL
+from signal import alarm, signal, SIGALRM, SIGINT, SIGKILL, SIGHUP
 import subprocess
 import fcntl
 import random
@@ -43,6 +43,7 @@ MAX_WAIT_TEST_RUN = 45*60
 
 interrupted = False
 old_sigint_handler = None
+got_sighup = False
 
 def setup_logging(log_level, log_file_name):
     logger = logging.getLogger()
@@ -105,6 +106,11 @@ def sigint_handler(signum, frame):
     print 'Press Ctrl-C again to abort now.'
     signal(SIGINT, old_sigint_handler)
 
+def sighup_handler(signum, frame):
+    global got_sighup
+    got_sighup = True
+    print 'SIGHUP: Will flush finished logs.'
+
 
 class MasterIsBusy(Exception):
 
@@ -339,7 +345,8 @@ class Section:
         if time.time() < self.sleep_until():
             return 0
 
-        do_processing = precedence is None or self.precedence() <= precedence
+        do_processing = not got_sighup and \
+                (precedence is None or self.precedence() <= precedence)
         if not do_processing and self._count_submittable_logs() == 0:
             return 0
 
@@ -471,6 +478,8 @@ class Section:
             self._slave.forget_reserved(package_name, version)
             if interrupted:
                 raise KeyboardInterrupt
+            if got_sighup:
+                break
         self._talk_to_master()
         return test_count
 
@@ -687,6 +696,7 @@ def create_file(filename, contents):
 
 def main():
     setup_logging(logging.INFO, None)
+    signal(SIGHUP, sighup_handler)
 
     # For supporting multiple architectures and suites, we take command-line
     # argument(s) referring to section(s) in the configuration file.
@@ -713,6 +723,12 @@ def main():
                 test_count += processed
                 precedence = section.precedence()
 
+        global got_sighup
+        if test_count == 0 and got_sighup:
+            # clear SIGHUP state after flushing all sections
+            got_sighup = False
+            continue
+
         if test_count == 0:
             now = time.time()
             sleep_until = min([now + int(global_config["idle-sleep"])] + [section.sleep_until() for section in sections])

-- 
piuparts git repository



More information about the Piuparts-commits mailing list