From d00ba778aeb21dd3e6d42c93af2d467971e0c9c4 Mon Sep 17 00:00:00 2001 From: Chris Pappas Date: Thu, 19 Dec 2024 14:20:31 -0500 Subject: [PATCH] fix: add more forgiving timeout duration for sdn backup (#87) * fix: add more forgiving timeout duration for sdn backup * chore: quality --- .../commands/populate_sdn_fallback_data_and_metadata.py | 2 +- .../management/commands/tests/test_download_sdn_fallback.py | 2 +- sanctions/settings/base.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sanctions/apps/sanctions/management/commands/populate_sdn_fallback_data_and_metadata.py b/sanctions/apps/sanctions/management/commands/populate_sdn_fallback_data_and_metadata.py index ecb06bd..8a80eab 100644 --- a/sanctions/apps/sanctions/management/commands/populate_sdn_fallback_data_and_metadata.py +++ b/sanctions/apps/sanctions/management/commands/populate_sdn_fallback_data_and_metadata.py @@ -53,7 +53,7 @@ def handle(self, *args, **options): # download the CSV locally, to check size and pass along to import threshold = options['threshold'] url = settings.CONSOLIDATED_SCREENING_LIST_URL - timeout = settings.SDN_CHECK_REQUEST_TIMEOUT + timeout = settings.SDN_BACKUP_REQUEST_TIMEOUT with requests.Session() as s: try: diff --git a/sanctions/apps/sanctions/management/commands/tests/test_download_sdn_fallback.py b/sanctions/apps/sanctions/management/commands/tests/test_download_sdn_fallback.py index 6509f50..472446d 100644 --- a/sanctions/apps/sanctions/management/commands/tests/test_download_sdn_fallback.py +++ b/sanctions/apps/sanctions/management/commands/tests/test_download_sdn_fallback.py @@ -151,7 +151,7 @@ def test_timeout_exception(self): self.LOGGER_NAME, 'WARNING', "Sanctions SDNFallback: DOWNLOAD FAILURE: Timeout occurred trying to download SDN CSV. " - "Timeout threshold (in seconds): 5" + "Timeout threshold (in seconds): 15" ) ) diff --git a/sanctions/settings/base.py b/sanctions/settings/base.py index 01e857e..d94b2db 100644 --- a/sanctions/settings/base.py +++ b/sanctions/settings/base.py @@ -97,6 +97,7 @@ def root(*path_fragments): # SDN Check SDN_CHECK_REQUEST_TIMEOUT = 5 # Value is in seconds. +SDN_BACKUP_REQUEST_TIMEOUT = 15 # Value is in seconds. # Settings to download the government CSL CONSOLIDATED_SCREENING_LIST_URL = 'https://data.trade.gov/downloadable_consolidated_screening_list/v1/consolidated.csv' # Settings to check government purchase restriction lists