Fix backgroundthreads and TypeError '<' not supported between instances

This commit is contained in:
croneter 2020-12-19 21:37:39 +01:00
parent 8bdfcbabc8
commit cc20464c15
2 changed files with 13 additions and 5 deletions

View file

@ -6,6 +6,7 @@ import threading
import queue
import heapq
from collections import deque
from functools import total_ordering
from . import utils, app, variables as v
@ -279,14 +280,20 @@ class Tasks(list):
self.pop().cancel()
@total_ordering
class Task(object):
def __init__(self, priority=None):
self.priority = priority
self._canceled = False
self.finished = False
def __cmp__(self, other):
return self.priority - other.priority
def __lt__(self, other):
"""Magic method Task<Other Task; compares the tasks' priorities."""
return self.priority - other.priority > 0
def __eq__(self, other):
"""Magic method Task=Other Task; compares the tasks' priorities."""
return self.priority == other.priority
def start(self):
BGThreader.addTask(self)

View file

@ -97,14 +97,15 @@ class Section(object):
"}}").format(self=self)
def __bool__(self):
"""Magic method to compare sections with =. section_id, name and
section_type must be set and be identical."""
return (self.section_id is not None and
self.name is not None and
self.section_type is not None)
def __eq__(self, section):
"""
Sections compare equal if their section_id, name and plex_type (first
prio) OR section_type (if there is no plex_type is set) compare equal
"""Sections compare equal if their section_id, name and plex_type (first
prio) OR section_type (if there is no plex_type is set) compare equal.
"""
return (self.section_id == section.section_id and
self.name == section.name and