Skip to content

Commit a84a181

Browse files
committed
wip
1 parent 8c2eb91 commit a84a181

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

pymongo/asynchronous/pool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,7 @@ async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> A
10661066
networking_interface = await _configured_protocol_interface(self.address, self.opts)
10671067
# Catch KeyboardInterrupt, CancelledError, etc. and cleanup.
10681068
except BaseException as error:
1069+
print("Got the TLS handshake error") # noqa: T201
10691070
async with self.lock:
10701071
self.active_contexts.discard(tmp_context)
10711072
if self.enabled_for_cmap:

pymongo/network_layer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class PyMongoBaseProtocol(Protocol):
254254
def __init__(self, timeout: Optional[float] = None):
255255
self.transport: Transport = None # type: ignore[assignment]
256256
self._timeout = timeout
257+
self._connection_made = asyncio.get_running_loop().create_future()
257258
self._closed = asyncio.get_running_loop().create_future()
258259
self._connection_lost = False
259260

@@ -270,7 +271,13 @@ def close(self, exc: Optional[Exception] = None) -> None:
270271
self._resolve_pending(exc)
271272
self._connection_lost = True
272273

274+
def connection_made(self, transport: BaseTransport) -> None:
275+
super().connection_made(transport)
276+
self._connection_made.set_result(None)
277+
273278
def connection_lost(self, exc: Optional[Exception] = None) -> None:
279+
if exc is not None and not self._connection_made.done():
280+
self._connection_made.set_exception(exc)
274281
self._resolve_pending(exc)
275282
if not self._closed.done():
276283
self._closed.set_result(None)
@@ -322,6 +329,7 @@ def connection_made(self, transport: BaseTransport) -> None:
322329
"""
323330
self.transport = transport # type: ignore[assignment]
324331
self.transport.set_write_buffer_limits(MAX_MESSAGE_SIZE, MAX_MESSAGE_SIZE)
332+
super().connection_made(self)
325333

326334
async def read(self, request_id: Optional[int], max_message_size: int) -> tuple[bytes, int]:
327335
"""Read a single MongoDB Wire Protocol message from this connection."""
@@ -489,6 +497,7 @@ def connection_made(self, transport: BaseTransport) -> None:
489497
The transport argument is the transport representing the write side of the connection.
490498
"""
491499
self.transport = transport # type: ignore[assignment]
500+
super().connection_made(self)
492501

493502
def data_received(self, data: bytes) -> None:
494503
if self._connection_lost:

pymongo/pool_shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ async def _configured_protocol_interface(
278278
server_hostname=host,
279279
ssl=ssl_context,
280280
)
281+
await protocol._connection_made
281282
except _CertificateError:
282283
# Raise _CertificateError directly like we do after match_hostname
283284
# below.

pymongo/synchronous/pool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> Connect
10621062
networking_interface = _configured_socket_interface(self.address, self.opts)
10631063
# Catch KeyboardInterrupt, CancelledError, etc. and cleanup.
10641064
except BaseException as error:
1065+
print("Got the TLS handshake error") # noqa: T201
10651066
with self.lock:
10661067
self.active_contexts.discard(tmp_context)
10671068
if self.enabled_for_cmap:

0 commit comments

Comments
 (0)