scanner: Add a function for clearing the TaskQueue
And call this function when closing the player Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
b245b2073e
commit
295202443f
|
@ -4,6 +4,7 @@ import lib
|
|||
lib.settings.load()
|
||||
|
||||
import db
|
||||
import scanner
|
||||
import ui
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
@ -22,6 +23,7 @@ class Application(Gtk.Application):
|
|||
|
||||
def do_shutdown(self):
|
||||
Gtk.Application.do_shutdown(self)
|
||||
scanner.Queue.clear()
|
||||
db.sql.optimize()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -17,6 +17,9 @@ class TaskQueue(GObject.GObject):
|
|||
def push(self, task):
|
||||
self.emit("task-pushed", task)
|
||||
|
||||
def clear(self):
|
||||
self.emit("tasks-finished")
|
||||
|
||||
def run(self):
|
||||
self.emit("run-task", self.tasks.pop(0))
|
||||
if len(self.tasks) > 0:
|
||||
|
|
|
@ -42,6 +42,16 @@ class TestTaskQueue(unittest.TestCase):
|
|||
self.assertIsNotNone(q.idleid)
|
||||
self.assertEqual(self.pushed_task, fake)
|
||||
|
||||
def test_clear(self):
|
||||
q = queue.TaskQueue()
|
||||
q.connect("tasks-finished", self.on_tasks_finished)
|
||||
|
||||
q.push(FakeTask())
|
||||
q.clear()
|
||||
self.assertEqual(q.tasks, [ ])
|
||||
self.assertTrue(self.tasks_finished)
|
||||
self.assertIsNone(q.idleid)
|
||||
|
||||
def test_run(self):
|
||||
q = queue.TaskQueue()
|
||||
fake3 = FakeTask()
|
||||
|
|
Loading…
Reference in New Issue