On Thu, 2007-07-26 at 10:41 -0400, Jeremy Katz wrote: > Per a suggestion on fedora-devel-list from Hans de Goede, the following > makes it so that we don't immediately exit on the command line if the > lock is held by another process. Instead, we spin checking every two > seconds to see if the lock has been released. This helps in the case > where, eg, yum-updatesd is downloading metadata so that you don't have > to guess when it's done. And if you don't want to wait, ctrl-c exits > immediately. > > Other opinions/thoughts?
One of the places I'd often like something like this is what I want to install something but have just ask yum to install something else, or do an update. So from that point of view I don't think 2 seconds is a good number, esp. given the message being printed out all the time. Power of 2 backoff upto a limit seems pretty easy to do. Updated patch attached. -- James Antill <[EMAIL PROTECTED]>
diff --git a/yum/__init__.py b/yum/__init__.py
index 2ab4bb2..3868838 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -656,7 +656,7 @@ class YumBase(depsolve.Depsolve):
raise Errors.LockError(1, msg)
else:
# Another copy seems to be running.
- msg = 'Existing lock %s: another copy is running as pid %s. Aborting.' % (lockfile, oldpid)
+ msg = 'Existing lock %s: another copy is running as pid %s.' % (lockfile, oldpid)
raise Errors.LockError(0, msg)
def doUnlock(self, lockfile = YUM_PID_FILE):
diff --git a/yummain.py b/yummain.py
index 8be78f4..795e82d 100755
--- a/yummain.py
+++ b/yummain.py
@@ -84,11 +84,27 @@ def main(args):
exPluginExit(e)
except Errors.YumBaseError, e:
exFatal(e)
- try:
- base.doLock()
- except Errors.LockError, e:
- logger.critical('%s', e.msg)
- sys.exit(200)
+
+ lockerr = ""
+ def pow2_num(num = 1, limit = 64):
+ """ Return increments of power of 2, with a limit. """
+ while True:
+ if num < lim:
+ num *= 2
+ yield num
+
+ lock_sleep_time = pow2_num()
+ while True:
+ try:
+ base.doLock()
+ except Errors.LockError, e:
+ if "%s" %(e.msg,) != lockerr:
+ lockerr = "%s" %(e.msg,)
+ logger.critical(lockerr)
+ logger.critical("Waiting for lock to be released...")
+ time.sleep(lock_sleep_time.next())
+ else:
+ break
try:
result, resultmsgs = base.doCommands()
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Yum-devel mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
