Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add queue_time and start_time, to get more info on when a specific qu… #6717

Merged
merged 2 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion medusa/generic_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ class QueuePriorities(object):


class GenericQueue(object):
def __init__(self):
def __init__(self, max_history=100):
self.currentItem = None
self.queue = []
self.history = []
self.max_history = max_history
self.queue_name = 'QUEUE'
self.min_priority = 0
self.lock = threading.Lock()
Expand Down Expand Up @@ -95,6 +97,7 @@ def sorter(x, y):
item=self.currentItem.name,
)
self.currentItem.start()
fifo(self.history, self.currentItem, self.max_history)

self.amActive = False

Expand All @@ -108,12 +111,22 @@ def __init__(self, name, action_id=0):
self.action_id = action_id
self.stop = threading.Event()
self.added = None
self.queue_time = datetime.datetime.now()
self.start_time = None

def run(self):
"""Implementing classes should call this."""
self.inProgress = True
self.start_time = datetime.datetime.now()

def finish(self):
"""Implementing Classes should call this."""
self.inProgress = False
threading.currentThread().name = self.name


def fifo(my_list, item, max_size=100):
"""Append item to queue and limit it to 100 items."""
if len(my_list) >= max_size:
my_list.pop(0)
my_list.append(item)
2 changes: 2 additions & 0 deletions medusa/search/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def get_episodes(search_thread, searchstatus):
ep.status, ep.quality,
manually_searched=ep.manually_searched
)],
'queuetime': search_thread.queue_time.isoformat(),
'starttime': search_thread.start_time.isoformat() if search_thread.start_time else None,
})

return results
Expand Down