From 9f8455256f253afbeff8f170365a2de4c42e97a5 Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Tue, 9 Jul 2013 12:58:27 +0200 Subject: software: YumWorker timeout parameters configurable 2 new configuration options supported: * [Yum] lock_wait_interval * [Yum] free_database_timeout --- src/software/lmi/software/yumdb/process.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/software/lmi/software/yumdb/process.py b/src/software/lmi/software/yumdb/process.py index 5686511..3b1c0d9 100644 --- a/src/software/lmi/software/yumdb/process.py +++ b/src/software/lmi/software/yumdb/process.py @@ -46,13 +46,7 @@ from lmi.software.yumdb.jobmanager import JobManager from lmi.software.util import cmpi_logging from lmi.software.yumdb.util import setup_logging -# ***************************************************************************** -# Constants -# ***************************************************************************** -# interval in seconds -FREE_DATABASE_TIMEOUT = 60 -LOCK_WAIT_INTERVAL = 0.5 -RPMDB_PATH = '/var/lib/rpm/Packages' +# Global variable which gets its value after the start of YumWorker process. LOG = None # ***************************************************************************** @@ -273,9 +267,10 @@ class YumWorker(Process): if exc.errno in (errno.EPERM, errno.EACCES, errno.ENOSPC): LOG.error("can't create lock file") raise errors.DatabaseLockError("Can't create lock file.") - LOG.info("trying to lock again after %.1f seconds", - LOCK_WAIT_INTERVAL) - time.sleep(LOCK_WAIT_INTERVAL) + timeout = util.Configuration.get_instance().get_safe( + 'Yum', 'LockWaitInterval', float) + LOG.info("trying to lock again after %.1f seconds", timeout) + time.sleep(timeout) @cmpi_logging.trace_method def _unlock_database(self): @@ -296,7 +291,9 @@ class YumWorker(Process): while True: if self._session_ended and self._session_level == 0: try: - return self._jobmgr.get_job(timeout=FREE_DATABASE_TIMEOUT) + timeout = util.Configuration.get_instance().get_safe( + 'Yum', 'FreeDatabaseTimeout', float) + return self._jobmgr.get_job(timeout=timeout) except TQueue.Empty: self._free_database() self._session_ended = False -- cgit