Commit 6c2ada5a authored by echel0n's avatar echel0n

Refactored queues to be watched via apscheduler 1s interval job.

parent 5f2b4f9d
......@@ -516,14 +516,42 @@ class Core(object):
id=self.announcements.name
)
# search queue
self.scheduler.add_job(
self.search_queue.run,
IntervalTrigger(
seconds=1,
timezone='utc'
),
name=self.search_queue.name,
id=self.search_queue.name
)
# show queue
self.scheduler.add_job(
self.show_queue.run,
IntervalTrigger(
seconds=1,
timezone='utc'
),
name=self.show_queue.name,
id=self.show_queue.name
)
# post-processor queue
self.scheduler.add_job(
self.postprocessor_queue.run,
IntervalTrigger(
seconds=1,
timezone='utc'
),
name=self.postprocessor_queue.name,
id=self.postprocessor_queue.name
)
# start scheduler service
self.scheduler.start()
# start queue's
self.io_loop.add_callback(self.search_queue.start)
self.io_loop.add_callback(self.show_queue.start)
self.io_loop.add_callback(self.postprocessor_queue.start)
# fire off startup events
self.io_loop.run_in_executor(None, self.quicksearch_cache.run)
self.io_loop.run_in_executor(None, self.name_cache.run)
......
......@@ -40,7 +40,7 @@ class SRQueuePriorities(object):
PAUSED = 99
class SRQueue(threading.Thread):
class SRQueue(object):
def __init__(self, name="QUEUE"):
super(SRQueue, self).__init__()
self.name = name
......@@ -59,14 +59,12 @@ class SRQueue(threading.Thread):
self.amActive = True
while not (self.stop and self.queue.empty()):
if not (self.stop and self.queue.empty()):
if not self.is_paused and not len(self.processing) >= int(sickrage.app.config.max_queue_workers):
sickrage.app.scheduler.add_job(self.worker, args=(self.queue.get(),))
# threading.Thread(target=self.worker, args=(self.queue.get(),)).start()
# sickrage.app.io_loop.run_in_executor(None, self.worker, self.get())
time.sleep(1)
self.amActive = False
def worker(self, item):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment