@@ -131,6 +131,7 @@ class AsyncConnection:
131
131
:param pool: a Pool instance
132
132
:param address: the server's (host, port)
133
133
:param id: the id of this socket in it's pool
134
+ :param is_sdam: SDAM connections do not call hello on creation
134
135
"""
135
136
136
137
def __init__ (
@@ -139,11 +140,13 @@ def __init__(
139
140
pool : Pool ,
140
141
address : tuple [str , int ],
141
142
id : int ,
143
+ is_sdam : bool ,
142
144
):
143
145
self .pool_ref = weakref .ref (pool )
144
146
self .conn = conn
145
147
self .address = address
146
148
self .id = id
149
+ self .is_sdam = is_sdam
147
150
self .closed = False
148
151
self .last_checkin_time = time .monotonic ()
149
152
self .performed_handshake = False
@@ -711,13 +714,13 @@ def __init__(
711
714
self ,
712
715
address : _Address ,
713
716
options : PoolOptions ,
714
- handshake : bool = True ,
717
+ is_sdam : bool = False ,
715
718
client_id : Optional [ObjectId ] = None ,
716
719
):
717
720
"""
718
721
:param address: a (hostname, port) tuple
719
722
: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
721
724
"""
722
725
if options .pause_enabled :
723
726
self .state = PoolState .PAUSED
@@ -746,14 +749,14 @@ def __init__(
746
749
self .pid = os .getpid ()
747
750
self .address = address
748
751
self .opts = options
749
- self .handshake = handshake
752
+ self .is_sdam = is_sdam
750
753
# Don't publish events or logs in Monitor pools.
751
754
self .enabled_for_cmap = (
752
- self .handshake
755
+ not self .is_sdam
753
756
and self .opts ._event_listeners is not None
754
757
and self .opts ._event_listeners .enabled_for_cmap
755
758
)
756
- self .enabled_for_logging = self .handshake
759
+ self .enabled_for_logging = not self .is_sdam
757
760
758
761
# The first portion of the wait queue.
759
762
# Enforces: maxPoolSize
@@ -1058,14 +1061,14 @@ async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> A
1058
1061
1059
1062
raise
1060
1063
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]
1062
1065
async with self .lock :
1063
1066
self .active_contexts .add (conn .cancel_context )
1064
1067
self .active_contexts .discard (tmp_context )
1065
1068
if tmp_context .cancelled :
1066
1069
conn .cancel_context .cancel ()
1067
1070
try :
1068
- if self .handshake :
1071
+ if not self .is_sdam :
1069
1072
await conn .hello ()
1070
1073
self .is_writable = conn .is_writable
1071
1074
if handler :
0 commit comments