Skip to content

Commit f1294dc

Browse files
committed
do not try and label errors
1 parent 5e34bdc commit f1294dc

File tree

3 files changed

+3
-25
lines changed

3 files changed

+3
-25
lines changed

pymongo/asynchronous/pool.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import asyncio
1818
import collections
1919
import contextlib
20-
import errno
2120
import logging
2221
import os
2322
import sys
@@ -1036,18 +1035,8 @@ def _handle_connection_error(self, error: BaseException, phase: str) -> None:
10361035
# errno == errno.ECONNRESET or raised from an OSError that we've created due to
10371036
# a closed connection.
10381037
# If found, set backoff and add error labels.
1039-
if self.is_sdam or type(error) != AutoReconnect or not len(error.errors):
1038+
if self.is_sdam or type(error) != AutoReconnect:
10401039
return
1041-
if hasattr(error.errors, "values"):
1042-
root_err = next(iter(error.errors.values()))
1043-
else:
1044-
root_err = error.errors[0]
1045-
if isinstance(root_err, ConnectionResetError):
1046-
if root_err.errno != errno.ECONNRESET:
1047-
return
1048-
elif isinstance(root_err, OSError):
1049-
if str(root_err) != "connection closed":
1050-
return
10511040
self._backoff += 1
10521041
error._add_error_label("SystemOverloadedError")
10531042
error._add_error_label("RetryableError")

pymongo/pool_shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def _raise_connection_failure(
149149
# 'timed out' appears in all the timeout related SSLErrors raised.
150150
raise NetworkTimeout(msg) from error
151151
else:
152-
raise AutoReconnect(msg, errors=[error]) from error
152+
raise AutoReconnect(msg) from error
153153

154154

155155
class _CancellationContext:

pymongo/synchronous/pool.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import asyncio
1818
import collections
1919
import contextlib
20-
import errno
2120
import logging
2221
import os
2322
import sys
@@ -1032,18 +1031,8 @@ def _handle_connection_error(self, error: BaseException, phase: str) -> None:
10321031
# errno == errno.ECONNRESET or raised from an OSError that we've created due to
10331032
# a closed connection.
10341033
# If found, set backoff and add error labels.
1035-
if self.is_sdam or type(error) != AutoReconnect or not len(error.errors):
1034+
if self.is_sdam or type(error) != AutoReconnect:
10361035
return
1037-
if hasattr(error.errors, "values"):
1038-
root_err = next(iter(error.errors.values()))
1039-
else:
1040-
root_err = error.errors[0]
1041-
if isinstance(root_err, ConnectionResetError):
1042-
if root_err.errno != errno.ECONNRESET:
1043-
return
1044-
elif isinstance(root_err, OSError):
1045-
if str(root_err) != "connection closed":
1046-
return
10471036
self._backoff += 1
10481037
error._add_error_label("SystemOverloadedError")
10491038
error._add_error_label("RetryableError")

0 commit comments

Comments
 (0)