about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/botocore/retries/special.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/botocore/retries/special.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/botocore/retries/special.py')
-rw-r--r--.venv/lib/python3.12/site-packages/botocore/retries/special.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/botocore/retries/special.py b/.venv/lib/python3.12/site-packages/botocore/retries/special.py
new file mode 100644
index 00000000..9b782601
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/botocore/retries/special.py
@@ -0,0 +1,51 @@
+"""Special cased retries.
+
+These are additional retry cases we still have to handle from the legacy
+retry handler.  They don't make sense as part of the standard mode retry
+module.  Ideally we should be able to remove this module.
+
+"""
+
+import logging
+from binascii import crc32
+
+from botocore.retries.base import BaseRetryableChecker
+
+logger = logging.getLogger(__name__)
+
+
+# TODO: This is an ideal candidate for the retryable trait once that's
+# available.
+class RetryIDPCommunicationError(BaseRetryableChecker):
+    _SERVICE_NAME = 'sts'
+
+    def is_retryable(self, context):
+        service_name = context.operation_model.service_model.service_name
+        if service_name != self._SERVICE_NAME:
+            return False
+        error_code = context.get_error_code()
+        return error_code == 'IDPCommunicationError'
+
+
+class RetryDDBChecksumError(BaseRetryableChecker):
+    _CHECKSUM_HEADER = 'x-amz-crc32'
+    _SERVICE_NAME = 'dynamodb'
+
+    def is_retryable(self, context):
+        service_name = context.operation_model.service_model.service_name
+        if service_name != self._SERVICE_NAME:
+            return False
+        if context.http_response is None:
+            return False
+        checksum = context.http_response.headers.get(self._CHECKSUM_HEADER)
+        if checksum is None:
+            return False
+        actual_crc32 = crc32(context.http_response.content) & 0xFFFFFFFF
+        if actual_crc32 != int(checksum):
+            logger.debug(
+                "DynamoDB crc32 checksum does not match, "
+                "expected: %s, actual: %s",
+                checksum,
+                actual_crc32,
+            )
+            return True