@@ -254,6 +254,7 @@ class PyMongoBaseProtocol(Protocol):
254
254
def __init__ (self , timeout : Optional [float ] = None ):
255
255
self .transport : Transport = None # type: ignore[assignment]
256
256
self ._timeout = timeout
257
+ self ._connection_made = asyncio .get_running_loop ().create_future ()
257
258
self ._closed = asyncio .get_running_loop ().create_future ()
258
259
self ._connection_lost = False
259
260
@@ -270,7 +271,13 @@ def close(self, exc: Optional[Exception] = None) -> None:
270
271
self ._resolve_pending (exc )
271
272
self ._connection_lost = True
272
273
274
+ def connection_made (self , transport : BaseTransport ) -> None :
275
+ super ().connection_made (transport )
276
+ self ._connection_made .set_result (None )
277
+
273
278
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 )
274
281
self ._resolve_pending (exc )
275
282
if not self ._closed .done ():
276
283
self ._closed .set_result (None )
@@ -322,6 +329,7 @@ def connection_made(self, transport: BaseTransport) -> None:
322
329
"""
323
330
self .transport = transport # type: ignore[assignment]
324
331
self .transport .set_write_buffer_limits (MAX_MESSAGE_SIZE , MAX_MESSAGE_SIZE )
332
+ super ().connection_made (self )
325
333
326
334
async def read (self , request_id : Optional [int ], max_message_size : int ) -> tuple [bytes , int ]:
327
335
"""Read a single MongoDB Wire Protocol message from this connection."""
@@ -489,6 +497,7 @@ def connection_made(self, transport: BaseTransport) -> None:
489
497
The transport argument is the transport representing the write side of the connection.
490
498
"""
491
499
self .transport = transport # type: ignore[assignment]
500
+ super ().connection_made (self )
492
501
493
502
def data_received (self , data : bytes ) -> None :
494
503
if self ._connection_lost :
0 commit comments