From 339ca9845ea401f19f65c41a91c0f388edf66724 Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Tue, 9 Jul 2013 12:55:28 +0200 Subject: software: more configurability of jobs asynchronous job's default priority made configurable with option [Jobs] default_priority asynchronous job's default timeout for removel made configurable with option [Jobs] default_time_before_removal --- src/software/lmi/software/yumdb/jobs.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/software/lmi') diff --git a/src/software/lmi/software/yumdb/jobs.py b/src/software/lmi/software/yumdb/jobs.py index 346ff17..098dfbf 100644 --- a/src/software/lmi/software/yumdb/jobs.py +++ b/src/software/lmi/software/yumdb/jobs.py @@ -33,10 +33,6 @@ from lmi.software.yumdb import errors from lmi.software.yumdb.packageinfo import PackageInfo from lmi.software.yumdb.repository import Repository -DEFAULT_JOB_PRIORITY = 10 -# in seconds -DEFAULT_TIME_BEFORE_REMOVAL = 60 * 5 - class YumJob(object): #pylint: disable=R0903 """ Base class for any job, that is processable by YumWorker process. @@ -83,7 +79,10 @@ class YumJob(object): #pylint: disable=R0903 """ return set(YumJob.__slots__) - def __init__(self, priority=10): + def __init__(self, priority=None): + if priority is None: + priority = util.Configuration.get_instance().get_safe( + 'Jobs', 'DefaultPriority', int) if not isinstance(priority, (int, long)): raise TypeError("priority must be integer") self.jobid = self._get_job_id() @@ -230,11 +229,12 @@ class YumAsyncJob(YumJob): #pylint: disable=R0903 def handle_ignore_job_props(cls): return YumJob.handle_ignore_job_props().union(YumAsyncJob.__slots__) - def __init__(self, priority=10, async=False, metadata=None): + def __init__(self, priority=None, async=False, metadata=None): YumJob.__init__(self, priority) self.async = bool(async) self.delete_on_completion = True - self.time_before_removal = DEFAULT_TIME_BEFORE_REMOVAL + self.time_before_removal = util.Configuration.get_instance().get_safe( + 'Jobs', 'DefaultTimeBeforeRemoval', float) if metadata is None and self.async is True: metadata = {} self.metadata = metadata -- cgit