Skip to content

Commit 69ae442

Browse files
committed
add logic to exclude SSL errors
1 parent 732cd6e commit 69ae442

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pymongo/asynchronous/pool.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
OperationFailure,
5858
PyMongoError,
5959
WaitQueueTimeoutError,
60+
_CertificateError,
6061
)
6162
from pymongo.hello import Hello, HelloCompat
6263
from pymongo.helpers_shared import _get_timeout_details, format_timeout_details
@@ -1029,6 +1030,9 @@ def _handle_connection_error(self, error: BaseException) -> None:
10291030
if self.is_sdam or type(error) not in (AutoReconnect, NetworkTimeout):
10301031
return
10311032
assert isinstance(error, AutoReconnect) # Appease type checker.
1033+
# If the original error was a certificate or SSL error, ignore it.
1034+
if isinstance(error.__cause__, (_CertificateError, SSLErrors)):
1035+
return
10321036
error._add_error_label("SystemOverloadedError")
10331037
error._add_error_label("RetryableError")
10341038

pymongo/synchronous/pool.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
OperationFailure,
5555
PyMongoError,
5656
WaitQueueTimeoutError,
57+
_CertificateError,
5758
)
5859
from pymongo.hello import Hello, HelloCompat
5960
from pymongo.helpers_shared import _get_timeout_details, format_timeout_details
@@ -1025,6 +1026,9 @@ def _handle_connection_error(self, error: BaseException) -> None:
10251026
if self.is_sdam or type(error) not in (AutoReconnect, NetworkTimeout):
10261027
return
10271028
assert isinstance(error, AutoReconnect) # Appease type checker.
1029+
# If the original error was a certificate or SSL error, ignore it.
1030+
if isinstance(error.__cause__, (_CertificateError, SSLErrors)):
1031+
return
10281032
error._add_error_label("SystemOverloadedError")
10291033
error._add_error_label("RetryableError")
10301034

0 commit comments

Comments
 (0)