summaryrefslogtreecommitdiffstats
path: root/src/software/lmi
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-07-09 12:55:28 +0200
committerMichal Minar <miminar@redhat.com>2013-07-23 13:52:35 +0200
commit339ca9845ea401f19f65c41a91c0f388edf66724 (patch)
treea2e8a76d4566c697f604bd6071f07ca6a07396ab /src/software/lmi
parentcc695fa0cf0f46b04e1e9a4ea34767721d48eb63 (diff)
downloadopenlmi-providers-339ca9845ea401f19f65c41a91c0f388edf66724.tar.gz
openlmi-providers-339ca9845ea401f19f65c41a91c0f388edf66724.tar.xz
openlmi-providers-339ca9845ea401f19f65c41a91c0f388edf66724.zip
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
Diffstat (limited to 'src/software/lmi')
-rw-r--r--src/software/lmi/software/yumdb/jobs.py14
1 files changed, 7 insertions, 7 deletions
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