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

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


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

    master: implement section locking
    
    Implement some simple section locking (fcntl.flock()), only works
    on local file systems.
    Prevents concurrent slaves to create concurrent master instances
    of the same section which would lead to races and duplicate
    reservations.
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index 5d36b23..17bf217 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,9 @@ piuparts (0.44) UNRELEASED; urgency=low
     - Increase output limit to 3 MB (for dist-upgrading daptup).
     - Do not miss Pre-Depends in --warn-on-others mode.
     - Remove packages and reinstall missing ones in one apt-get call.
+  * piuparts-master.py:
+    - Implement simple section locking to allow concurrent master instances
+      but allow only one instance per section.
   * piuparts-report.py:
     - Add link to the list of untestable logs.
     - Add more known problem reports: forgotten alternatives, warnings in
@@ -40,7 +43,6 @@ piuparts (0.43) unstable; urgency=low
     - Cleanup options and settings.
   * piupartslib/packagesdb.py:
     - Restrict circular-dependency state to packages on the circle.
-  * piuparts-master.py:
   * piuparts-slave.py:
     - Fix chdir in/out of the slave dir to work with relative paths.
   * piuparts-report.py:
diff --git a/piuparts-master.py b/piuparts-master.py
index feb89d4..04bb7f5 100644
--- a/piuparts-master.py
+++ b/piuparts-master.py
@@ -27,6 +27,7 @@ import sys
 import logging
 import ConfigParser
 import os
+import fcntl
 
 import piupartslib
 
@@ -216,6 +217,13 @@ def main():
         if not os.path.exists(os.path.join(master_directory, section)):
           os.makedirs(os.path.join(master_directory, section))
 
+        lock = open(os.path.join(master_directory, section, "master.lock"), "we")
+        try:
+            fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
+        except IOError:
+            print 'busy'
+            sys.exit(1)
+
         logging.info("Fetching %s" % config["packages-url"])
         packages_file = piupartslib.open_packages_url(config["packages-url"])
         known_circular_depends = config["known_circular_depends"]

-- 
piuparts git repository



More information about the Piuparts-commits mailing list