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

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


The following commit has been merged in the develop branch:
commit ac51d65a71e6cedfbe9189651e1445939b650638
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Fri Jul 20 01:19:56 2012 +0200

    p-m: delay Packages file load until needed
    
    Fetching and parsing the Packages file is slow and only needed
    for computing status and reserving packages.
    Submitting logs works fine (and much faster) without.
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index 6701ccb..8b216f0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,8 @@ piuparts (0.46) UNRELEASED; urgency=low
   * piuparts-master.py:
     - Accept and discard duplicate log submissions, preventing the slave from
       retrying infinitely.
+    - Delay loading the Packages file which is only needed for "status" and
+      "reserve" commands, but not for submitting logs.
   * piuparts-slave.py:
     - Fix stopping the currently running test (Ctrl-C Ctrl-C).
     - Handle master communication exceptions while sending logs or reserving
diff --git a/piuparts-master.py b/piuparts-master.py
index 543bc74..ee8a9d4 100644
--- a/piuparts-master.py
+++ b/piuparts-master.py
@@ -129,12 +129,20 @@ class Master(Protocol):
             "untestable": self._untestable,
         }
         self._section = section
-        self._package_databases = {}
+        self._package_databases = None
+        # start with a dummy _binary_db (without Packages file), sufficient
+        # for submitting finished logs
         self._binary_db = piupartslib.packagesdb.PackagesDB(prefix=section)
-        self._load_package_database(section)
-        self._binary_db = self._package_databases[section]
         self._writeline("hello")
 
+    def _init_db(self):
+        if self._package_databases is not None:
+            return
+
+        self._package_databases = {}
+        self._load_package_database(self._section)
+        self._binary_db = self._package_databases[self._section]
+
     def _load_package_database(self, section):
         config = Config(section=section, defaults_section="global")
         config.read(CONFIG_FILE)
@@ -168,6 +176,7 @@ class Master(Protocol):
 
     def _status(self, command, args):
         self._check_args(0, command, args)
+        self._init_db()
         stats = ""
         total = 0
         for state in self._binary_db.get_states():
@@ -179,6 +188,7 @@ class Master(Protocol):
 
     def _reserve(self, command, args):
         self._check_args(0, command, args)
+        self._init_db()
         package = self._binary_db.reserve_package()
         if package is None:
             self._short_response("error")

-- 
piuparts git repository



More information about the Piuparts-commits mailing list