extras-buildsys/server Repo.py,1.16.2.3.4.5,1.16.2.3.4.6

Michael Schwendt mschwendt at fedoraproject.org
Mon Sep 29 16:05:54 UTC 2008


Author: mschwendt

Update of /cvs/fedora/extras-buildsys/server
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv28463/server

Modified Files:
      Tag: Plague-0_4_5
	Repo.py 
Log Message:
- add and use LockFile module with optional POSIX locking-style
- pushscript reuses this module



Index: Repo.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/Repo.py,v
retrieving revision 1.16.2.3.4.5
retrieving revision 1.16.2.3.4.6
diff -u -r1.16.2.3.4.5 -r1.16.2.3.4.6
--- Repo.py	29 Sep 2008 10:44:15 -0000	1.16.2.3.4.5
+++ Repo.py	29 Sep 2008 16:05:54 -0000	1.16.2.3.4.6
@@ -6,7 +6,7 @@
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Library General Public License for more details.
+# GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
@@ -24,6 +24,7 @@
 import stat
 import EmailUtils
 from plague import DebugUtils
+from plague.LockFile import LockFile, LockFileLocked
 
 # Lockfile used by external scripts to ensure mutual exclusion
 # from concurrent access to the repository's directory
@@ -68,6 +69,11 @@
         if len(script):
             self._repo_script = script
 
+        if parent_cfg.has_option('General','locktype'):
+            self._locktype = parent_cfg.get_str('General','locktype')
+        else:
+            self._locktype = 'flock'
+
         threading.Thread.__init__(self)
         self.setName("Repo: %s" % target_str)
 
@@ -92,20 +98,17 @@
         return False
 
     def _update_repo_with_pushlock(self):
-        lockfile = None
+        lockfile = LockFile(name=self._lockfile_path,blocking=True,type=self._locktype)
         try:
-            lockfile = open(self._lockfile_path, 'w')
-            rc = fcntl.flock(lockfile, fcntl.LOCK_EX)
+            lockfile.lock()
         except IOError, (errno, strerr):
             target_str = self._target_cfg.target_string()
             print "Repo Error (%s): opening lockfile %s failed.  Output: (errno %d) '%s'" % (target_str, self._lockfile_path, errno, strerr)
-
         try:
             self._update_repo()
         finally:
-            if lockfile:
-                fcntl.flock(lockfile, fcntl.LOCK_UN)
-                lockfile.close()
+            lockfile.unlock()
+
 
     def _update_repo(self):
         """ Copy new RPMS to each repo, and update each repo at the end """




More information about the fedora-extras-commits mailing list