Skip to content

Commit

Permalink
mitigation for frequent metadata sync timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed Dec 3, 2019
1 parent 0ac44b6 commit 136163d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 4 additions & 1 deletion securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions securedrop_client/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 136163d

Please sign in to comment.