From 136163d74dfc9137f08a9d306bf978b556ada827 Mon Sep 17 00:00:00 2001 From: Allie Crevier Date: Fri, 8 Nov 2019 01:20:00 -0800 Subject: [PATCH] mitigation for frequent metadata sync timeouts --- securedrop_client/logic.py | 5 ++++- securedrop_client/queue.py | 10 ++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/securedrop_client/logic.py b/securedrop_client/logic.py index 0a104923ac..b6dd34491f 100644 --- a/securedrop_client/logic.py +++ b/securedrop_client/logic.py @@ -307,9 +307,12 @@ def login(self, username, password, totp): """ Given a username, password and time based one-time-passcode (TOTP), create a new instance representing the SecureDrop api and authenticate. + + Default to 60 seconds until we implement a better request timeout strategy. """ storage.mark_all_pending_drafts_as_failed(self.session) - self.api = sdclientapi.API(self.hostname, username, password, totp, self.proxy) + self.api = sdclientapi.API( + self.hostname, username, password, totp, self.proxy, default_request_timeout=60) self.call_api(self.api.authenticate, self.on_authenticate_success, self.on_authenticate_failure) diff --git a/securedrop_client/queue.py b/securedrop_client/queue.py index 934486e04e..58aec7f2aa 100644 --- a/securedrop_client/queue.py +++ b/securedrop_client/queue.py @@ -136,13 +136,12 @@ class ApiJobQueue(QObject): def __init__(self, api_client: API, session_maker: scoped_session) -> None: super().__init__(None) - self.api_client = api_client self.main_thread = QThread() self.download_file_thread = QThread() - self.main_queue = RunnableQueue(self.api_client, session_maker) - self.download_file_queue = RunnableQueue(self.api_client, session_maker) + self.main_queue = RunnableQueue(api_client, session_maker) + self.download_file_queue = RunnableQueue(api_client, session_maker) self.main_queue.moveToThread(self.main_thread) self.download_file_queue.moveToThread(self.download_file_thread) @@ -159,11 +158,6 @@ def logout(self) -> None: def login(self, api_client: API) -> None: logger.debug('Passing API token to queues') - - # Setting realistic (shorter) timeout for general requests so that user feedback - # is faster - api_client.default_request_timeout = 5 - self.main_queue.api_client = api_client self.download_file_queue.api_client = api_client self.start_queues()