diff --git a/pymongo/pyopenssl_context.py b/pymongo/pyopenssl_context.py index 50d8680a74..a320e94929 100644 --- a/pymongo/pyopenssl_context.py +++ b/pymongo/pyopenssl_context.py @@ -125,7 +125,8 @@ def _call(self, call: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: try: return call(*args, **kwargs) except BLOCKING_IO_ERRORS as exc: - if is_async: + # Do not retry if the connection is in non-blocking mode. + if is_async or timeout == 0: raise exc # Check for closed socket. if self.fileno() == -1: