extras-buildsys/utils extras-push-new,1.21,1.22
Michael Schwendt (mschwendt)
fedora-extras-commits at redhat.com
Fri Jun 2 22:05:22 UTC 2006
Author: mschwendt
Update of /cvs/fedora/extras-buildsys/utils
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22324
Modified Files:
extras-push-new
Log Message:
enhance/extend the LockFile class for further use
Index: extras-push-new
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/extras-push-new,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- extras-push-new 2 Jun 2006 22:04:26 -0000 1.21
+++ extras-push-new 2 Jun 2006 22:05:20 -0000 1.22
@@ -104,19 +104,22 @@
class LockFile:
- def __init__(self, name):
+ def __init__(self, name, blocking=False):
self.name = name
+ self.mode = fcntl.LOCK_EX
+ if not blocking:
+ self.mode |= fcntl.LOCK_NB
def lock(self):
if DEBUG:
return
- self.file = open(self.name,'w')
try:
- self.rc = fcntl.flock(self.file, fcntl.LOCK_EX | fcntl.LOCK_NB)
- except IOError:
- print 'ERROR: script locked via lockfile %s - it seems to be running already' % self.name
- sys.exit(errno.EAGAIN)
+ self.file = open(self.name,'w')
+ except IOError, (errno, strerr):
+ print "ERROR: opening lockfile %s failed: %s (error %d)" % (self.name, strerr, errno)
+ sys.exit(errno)
+ self.rc = fcntl.flock(self.file, self.mode)
def unlock(self):
@@ -531,7 +534,11 @@
lockfile = os.path.join(rundir,'extras-push.lock')
lock = LockFile(lockfile)
- lock.lock()
+ try:
+ lock.lock()
+ except IOError:
+ print 'ERROR: script locked via lockfile %s - it seems to be running already' % lockfile
+ sys.exit(errno.EPERM)
for dist in diststopush:
result = sign_move(dist)
More information about the scm-commits
mailing list