@@ -131,6 +131,7 @@ class AsyncConnection:
131131 :param pool: a Pool instance
132132 :param address: the server's (host, port)
133133 :param id: the id of this socket in it's pool
134+ :param is_sdam: SDAM connections do not call hello on creation
134135 """
135136
136137 def __init__ (
@@ -139,11 +140,13 @@ def __init__(
139140 pool : Pool ,
140141 address : tuple [str , int ],
141142 id : int ,
143+ is_sdam : bool ,
142144 ):
143145 self .pool_ref = weakref .ref (pool )
144146 self .conn = conn
145147 self .address = address
146148 self .id = id
149+ self .is_sdam = is_sdam
147150 self .closed = False
148151 self .last_checkin_time = time .monotonic ()
149152 self .performed_handshake = False
@@ -711,13 +714,13 @@ def __init__(
711714 self ,
712715 address : _Address ,
713716 options : PoolOptions ,
714- handshake : bool = True ,
717+ is_sdam : bool = False ,
715718 client_id : Optional [ObjectId ] = None ,
716719 ):
717720 """
718721 :param address: a (hostname, port) tuple
719722 :param options: a PoolOptions instance
720- :param handshake : whether to call hello for each new AsyncConnection
723+ :param is_sdam : whether to call hello for each new AsyncConnection
721724 """
722725 if options .pause_enabled :
723726 self .state = PoolState .PAUSED
@@ -746,14 +749,14 @@ def __init__(
746749 self .pid = os .getpid ()
747750 self .address = address
748751 self .opts = options
749- self .handshake = handshake
752+ self .is_sdam = is_sdam
750753 # Don't publish events or logs in Monitor pools.
751754 self .enabled_for_cmap = (
752- self .handshake
755+ not self .is_sdam
753756 and self .opts ._event_listeners is not None
754757 and self .opts ._event_listeners .enabled_for_cmap
755758 )
756- self .enabled_for_logging = self .handshake
759+ self .enabled_for_logging = not self .is_sdam
757760
758761 # The first portion of the wait queue.
759762 # Enforces: maxPoolSize
@@ -1058,14 +1061,14 @@ async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> A
10581061
10591062 raise
10601063
1061- conn = AsyncConnection (networking_interface , self , self .address , conn_id ) # type: ignore[arg-type]
1064+ conn = AsyncConnection (networking_interface , self , self .address , conn_id , self . is_sdam ) # type: ignore[arg-type]
10621065 async with self .lock :
10631066 self .active_contexts .add (conn .cancel_context )
10641067 self .active_contexts .discard (tmp_context )
10651068 if tmp_context .cancelled :
10661069 conn .cancel_context .cancel ()
10671070 try :
1068- if self .handshake :
1071+ if not self .is_sdam :
10691072 await conn .hello ()
10701073 self .is_writable = conn .is_writable
10711074 if handler :
0 commit comments