Skip to content

Commit

Permalink
ipdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed May 20, 2019
1 parent c9d0253 commit fd6b8b7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions securedrop_client/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


Expand All @@ -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()
Expand Down

0 comments on commit fd6b8b7

Please sign in to comment.