diff --git a/securedrop_client/queue.py b/securedrop_client/queue.py index 39c1153acd..5d6acd9296 100644 --- a/securedrop_client/queue.py +++ b/securedrop_client/queue.py @@ -76,7 +76,10 @@ def __init__(self, api_client: API, halt_signal: pyqtBoundSignal) -> None: def stop(self) -> None: self.run = False - def __call__(self, loop: bool = True) -> None: + def start(self, test_loop: bool = False) -> None: + """ + test_loop is for testing purposes only + """ while self.run: # retry the "cached" job if it exists, otherwise get the next job job = self.last_job or self.queue.get(block=True) @@ -90,7 +93,7 @@ def __call__(self, loop: bool = True) -> None: self.last_job = job # "cache" the last job since we can't re-queue it return - if not loop: + if test_loop: return @@ -109,18 +112,14 @@ def __init__(self, api_client: API, parent: Optional[QObject] = None) -> None: self.download_queue = RunnableQueue(self.api_client, self.halt_signal) def start_queues(self) -> None: - # ensure the queues are set to run (for previously stopped threads) - self.main_queue.run = True - self.download_queue.run = True - main_thread = QThread(self) download_thread = QThread(self) self.main_queue.moveToThread(main_thread) self.download_queue.moveToThread(download_thread) - # main_thread.started.connect(self.main_queue) - # download_thread.started.connect(self.download_queue) + main_thread.started.connect(self.main_queue.start) + download_thread.started.connect(self.download_queue.start) main_thread.start() download_thread.start()