[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.42-59-gc28b2f1
Andreas Beckmann
debian at abeckmann.de
Sat Mar 10 09:08:51 UTC 2012
The following commit has been merged in the develop branch:
commit 6511d6350fa7e1faf36031fd9a049dd1f4763026
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Mon Mar 5 17:57:36 2012 +0100
implement section locking
Implement some simple section locking (fcntl.flock()), only works
on local file systems.
Allows to run multiple slave instances in parallel (but a section
can only be processed by one slave at a time).
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/debian/changelog b/debian/changelog
index b4887e2..8daf45a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,7 @@ piuparts (0.44) UNRELEASED; urgency=low
* piuparts-slave.py:
- Do not leak the logfile file descriptor to piuparts.
- Do not abort if connection to master failed, just skip the section.
+ - Implement simple section locking to allow concurrent slave instances.
* 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 8b3c51e..22724f9 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -30,6 +30,7 @@ import time
import logging
from signal import alarm, signal, SIGALRM, SIGKILL
import subprocess
+import fcntl
import ConfigParser
import piupartslib.conf
@@ -302,12 +303,21 @@ class Section:
self._config = Config(section=self._config.section)
self._config.read(CONFIG_FILE)
+ lock = open(os.path.join(self._slave_directory, "slave.lock"), "we")
+ try:
+ fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError:
+ logging.info("busy")
+ lock.close()
+ return 0
+
oldcwd = os.getcwd()
os.chdir(self._slave_directory)
ret = self._run()
os.chdir(oldcwd)
+ lock.close()
return ret
def _run(self):
--
piuparts git repository
More information about the Piuparts-commits
mailing list