diff options
author | Michal Minar <miminar@redhat.com> | 2013-11-08 16:04:29 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-11-08 16:04:29 +0100 |
commit | 2de64ba34ef7dda1763898441407c6f96a944fec (patch) | |
tree | 0e808a1a4b3b265a84f1cda6088d6b8057666585 /src/software | |
parent | 2b0214c22bd97d09d934d53fc186b5477b7a6665 (diff) | |
download | openlmi-providers-2de64ba34ef7dda1763898441407c6f96a944fec.tar.gz openlmi-providers-2de64ba34ef7dda1763898441407c6f96a944fec.tar.xz openlmi-providers-2de64ba34ef7dda1763898441407c6f96a944fec.zip |
software: fixed shutting down of job manager
When job manager received None command (which says "shut down") it
is was enqueued into priority queue where comparison functions did not
count with None as a valid object. This does not have inpact on
functionality (job manager and YumWorker terminate anyway) but the
terminating message is not written into log due to an AttributeError.
This modifies comparison function to accept None and give it the highest
priority.
Diffstat (limited to 'src/software')
-rw-r--r-- | src/software/lmi/software/yumdb/jobs.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/software/lmi/software/yumdb/jobs.py b/src/software/lmi/software/yumdb/jobs.py index 4b8fe84..c30a875 100644 --- a/src/software/lmi/software/yumdb/jobs.py +++ b/src/software/lmi/software/yumdb/jobs.py @@ -171,15 +171,18 @@ class YumJob(object): #pylint: disable=R0903 """ JobControl jobs have the highest priority. """ - return ( ( isinstance(self, YumJobControl) - and not isinstance(other, YumJobControl)) - or ( self.priority < other.priority - or ( self.priority == other.priority - and ( self.jobid < other.jobid - or ( self.jobid == other.jobid - and (self.created < other.created)))))) + return ( other is not None # terminating command + and ( ( isinstance(self, YumJobControl) + and not isinstance(other, YumJobControl)) + or ( self.priority < other.priority + or ( self.priority == other.priority + and ( self.jobid < other.jobid + or ( self.jobid == other.jobid + and (self.created < other.created))))))) def __cmp__(self, other): + if other is None: # terminating command + return 1 if ( isinstance(self, YumJobControl) and not isinstance(other, YumJobControl)): return -1 |