A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fixes handling of exception chains in the util
Trenton Ha2f738772ca4
diff --git a/src/documents/tests/utils.py b/src/documents/tests/utils.pyindex c679a8f02..815a5d0b6 100644--- a/src/documents/tests/utils.py+++ b/src/documents/tests/utils.py@@ -24,6 +24,7 @@ from django.test import override_settingsfrom documents.data_models import ConsumableDocumentfrom documents.data_models import DocumentMetadataOverrides+from documents.parsers import ParseErrordef setup_directories():@@ -89,7 +90,7 @@ def util_call_with_backoff(method_or_callable: Callable,args: Union[List, Tuple],*,- skip_on_503=True,+ skip_on_50x_err=True,) -> Tuple[bool, Any]:"""For whatever reason, the images started during the test pipeline like to@@ -118,24 +119,30 @@ def util_call_with_backoff(result = method_or_callable(*args)succeeded = True- except httpx.HTTPError as exc:- warnings.warn(f"HTTP Exception for {exc.request.url} - {exc}")-- if isinstance(exc, httpx.HTTPStatusError):- status_codes.append(exc.response.status_code)-- retry_count = retry_count + 1-- time.sleep(retry_time)- retry_time = retry_time * 2.0+ except ParseError as e:+ cause_exec = e.__cause__+ if cause_exec is not None and isinstance(cause_exec, httpx.HTTPStatusError):+ status_codes.append(cause_exec.response.status_code)+ warnings.warn(+ f"HTTP Exception for {cause_exec.request.url} - {cause_exec}",+ )+ else:+ warnings.warn(f"Unexpected error: {e}")+ except Exception as e:+ warnings.warn(f"Unexpected error: {e}")++ retry_count = retry_count + 1++ time.sleep(retry_time)+ retry_time = retry_time * 2.0if (not succeededand status_codes- and skip_on_503- and all(element == httpx.codes.SERVICE_UNAVAILABLE for element in status_codes)+ and skip_on_50x_err+ and all(httpx.codes.is_server_error(code) for code in status_codes)):- pytest.skip("Repeated HTTP 503 for service")+ pytest.skip("Repeated HTTP 50x for service")return succeeded, result