Skip to content

Commit 02201d2

Browse files
committed
AC review
1 parent 49302f9 commit 02201d2

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

pymongo/asynchronous/client_bulk.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
InvalidOperation,
6060
NotPrimaryError,
6161
OperationFailure,
62+
PyMongoError,
6263
WaitQueueTimeoutError,
6364
)
6465
from pymongo.helpers_shared import _RETRYABLE_ERROR_CODES
@@ -563,13 +564,9 @@ async def _execute_command(
563564
error, ConnectionFailure
564565
) and not isinstance(error, (NotPrimaryError, WaitQueueTimeoutError))
565566

566-
retryable_label_error = (
567-
hasattr(error, "details")
568-
and isinstance(error.details, dict)
569-
and "errorLabels" in error.details
570-
and isinstance(error.details["errorLabels"], list)
571-
and "RetryableError" in error.details["errorLabels"]
572-
)
567+
retryable_label_error = isinstance(
568+
error, PyMongoError
569+
) and error.has_error_label("RetryableError")
573570

574571
# Synthesize the full bulk result without modifying the
575572
# current one because this write operation may be retried.

pymongo/synchronous/client_bulk.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
InvalidOperation,
6060
NotPrimaryError,
6161
OperationFailure,
62+
PyMongoError,
6263
WaitQueueTimeoutError,
6364
)
6465
from pymongo.helpers_shared import _RETRYABLE_ERROR_CODES
@@ -561,13 +562,9 @@ def _execute_command(
561562
error, ConnectionFailure
562563
) and not isinstance(error, (NotPrimaryError, WaitQueueTimeoutError))
563564

564-
retryable_label_error = (
565-
hasattr(error, "details")
566-
and isinstance(error.details, dict)
567-
and "errorLabels" in error.details
568-
and isinstance(error.details["errorLabels"], list)
569-
and "RetryableError" in error.details["errorLabels"]
570-
)
565+
retryable_label_error = isinstance(
566+
error, PyMongoError
567+
) and error.has_error_label("RetryableError")
571568

572569
# Synthesize the full bulk result without modifying the
573570
# current one because this write operation may be retried.

0 commit comments

Comments
 (0)