From 5831934b379e2a3c634778e92feed41837d4c9b2 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 5 Jun 2023 12:03:51 -0500 Subject: [PATCH] PYTHON-3691 [Build Failure] test_client.TestClient.test_exhaust_network_error (#1216) --- pymongo/pyopenssl_context.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pymongo/pyopenssl_context.py b/pymongo/pyopenssl_context.py index bfc52df67..83d8f853e 100644 --- a/pymongo/pyopenssl_context.py +++ b/pymongo/pyopenssl_context.py @@ -107,6 +107,11 @@ class _sslConn(_SSL.Connection): try: return call(*args, **kwargs) except BLOCKING_IO_ERRORS as exc: + # Check for closed socket. + if self.fileno() == -1: + if timeout and _time.monotonic() - start > timeout: + raise _socket.timeout("timed out") + raise SSLError("Underlying socket has been closed") if isinstance(exc, _SSL.WantReadError): want_read = True want_write = False