@@ -250,6 +250,7 @@ async def _configured_protocol_interface(
250
250
address : _Address ,
251
251
options : PoolOptions ,
252
252
protocol_kls : type [PyMongoBaseProtocol ] = PyMongoProtocol ,
253
+ context : dict [str , bool ] | None = None ,
253
254
) -> AsyncNetworkingInterface :
254
255
"""Given (host, port) and PoolOptions, return a configured AsyncNetworkingInterface.
255
256
@@ -261,6 +262,10 @@ async def _configured_protocol_interface(
261
262
ssl_context = options ._ssl_context
262
263
timeout = options .socket_timeout
263
264
265
+ # Signal that we have created the socket successfully.
266
+ if context :
267
+ context ["has_created_socket" ] = True
268
+
264
269
if ssl_context is None :
265
270
return AsyncNetworkingInterface (
266
271
await asyncio .get_running_loop ().create_connection (
@@ -374,7 +379,7 @@ def _create_connection(address: _Address, options: PoolOptions) -> socket.socket
374
379
375
380
376
381
def _configured_socket_interface (
377
- address : _Address , options : PoolOptions , * args : Any
382
+ address : _Address , options : PoolOptions , * args : Any , context : dict [ str , bool ] | None = None
378
383
) -> NetworkingInterface :
379
384
"""Given (host, port) and PoolOptions, return a NetworkingInterface wrapping a configured socket.
380
385
@@ -385,6 +390,10 @@ def _configured_socket_interface(
385
390
sock = _create_connection (address , options )
386
391
ssl_context = options ._ssl_context
387
392
393
+ # Signal that we have created the socket successfully.
394
+ if context :
395
+ context ["has_created_socket" ] = True
396
+
388
397
if ssl_context is None :
389
398
sock .settimeout (options .socket_timeout )
390
399
return NetworkingInterface (sock )
0 commit comments