[Piuparts-commits] [SCM] piuparts git repository branch, piatti, updated. 0.45-75-g5fca52d
Andreas Beckmann
debian at abeckmann.de
Thu Jul 26 12:13:27 UTC 2012
The following commit has been merged in the piatti branch:
commit 4482b81b21bddb8f22bab47a9673549e3d473376
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Thu Jun 21 18:35:53 2012 +0200
p-s: use with to scope the lock file
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/piuparts-slave.py b/piuparts-slave.py
index b9301f8..cf1829f 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -337,23 +337,21 @@ class Section:
self._error_wait_until = time.time() + 3600
return 0
- 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")
- self._error_wait_until = time.time() + 900
- lock.close()
- return 0
+ with open(os.path.join(self._slave_directory, "slave.lock"), "we") as lock:
+ try:
+ fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError:
+ logging.info("busy")
+ self._error_wait_until = time.time() + 900
+ return 0
- oldcwd = os.getcwd()
- os.chdir(self._slave_directory)
+ oldcwd = os.getcwd()
+ os.chdir(self._slave_directory)
- ret = self._run()
+ ret = self._run()
- os.chdir(oldcwd)
- lock.close()
- return ret
+ os.chdir(oldcwd)
+ return ret
def _run(self):
try:
--
piuparts git repository
More information about the Piuparts-commits
mailing list