@@ -735,7 +735,7 @@ def __init__(
735
735
self .__cursor_manager = None
736
736
self .__kill_cursors_queue = []
737
737
738
- self ._event_listeners = options .pool_options .event_listeners
738
+ self ._event_listeners = options .pool_options ._event_listeners
739
739
740
740
# Cache of existing indexes used by ensure_index ops.
741
741
self .__index_cache = {}
@@ -749,7 +749,7 @@ def __init__(
749
749
)
750
750
751
751
self .__all_credentials = {}
752
- creds = options .credentials
752
+ creds = options ._credentials
753
753
if creds :
754
754
self ._cache_credentials (creds .source , creds )
755
755
@@ -1017,10 +1017,14 @@ def watch(
1017
1017
1018
1018
@property
1019
1019
def event_listeners (self ):
1020
- """The event listeners registered for this client.
1020
+ """**DEPRECATED**: The event listeners registered for this client.
1021
1021
1022
1022
See :mod:`~pymongo.monitoring` for details.
1023
+
1024
+ .. versionchanged:: 3.13
1025
+ Deprecated. Use ``client.options.event_listeners`` instead.
1023
1026
"""
1027
+ warnings .warn ("event_listeners is deprecated. Use ``client.options.event_listeners`` instead." , DeprecationWarning , stacklevel = 2 )
1024
1028
return self ._event_listeners .event_listeners
1025
1029
1026
1030
@property
@@ -1132,7 +1136,7 @@ def is_mongos(self):
1132
1136
1133
1137
@property
1134
1138
def max_pool_size (self ):
1135
- """The maximum allowable number of concurrent connections to each
1139
+ """**DEPRECATED**: The maximum allowable number of concurrent connections to each
1136
1140
connected server. Requests to a server will block if there are
1137
1141
`maxPoolSize` outstanding connections to the requested server.
1138
1142
Defaults to 100. Cannot be 0.
@@ -1142,22 +1146,33 @@ def max_pool_size(self):
1142
1146
``waitQueueTimeoutMS`` is set, a blocked operation will raise
1143
1147
:exc:`~pymongo.errors.ConnectionFailure` after a timeout.
1144
1148
By default ``waitQueueTimeoutMS`` is not set.
1149
+
1150
+ .. versionchanged:: 3.13
1151
+ Deprecated. Use ``client.options.pool_options.max_pool_size`` instead.
1145
1152
"""
1153
+ warnings .warn ("max_pool_size is deprecated. Use ``client.options.pool_options.max_pool_size`` instead." , DeprecationWarning , stacklevel = 2 )
1146
1154
return self .__options .pool_options .max_pool_size
1147
1155
1148
1156
@property
1149
1157
def min_pool_size (self ):
1150
- """The minimum required number of concurrent connections that the pool
1158
+ """**DEPRECATED**: The minimum required number of concurrent connections that the pool
1151
1159
will maintain to each connected server. Default is 0.
1160
+ .. versionchanged:: 3.13
1161
+ Deprecated.
1152
1162
"""
1163
+ warnings .warn ("min_pool_size is deprecated. Use ``client.options.pool_options.min_pool_size`` instead." , DeprecationWarning , stacklevel = 2 )
1153
1164
return self .__options .pool_options .min_pool_size
1154
1165
1155
1166
@property
1156
1167
def max_idle_time_ms (self ):
1157
- """The maximum number of milliseconds that a connection can remain
1168
+ """**DEPRECATED**: The maximum number of milliseconds that a connection can remain
1158
1169
idle in the pool before being removed and replaced. Defaults to
1159
1170
`None` (no limit).
1171
+
1172
+ .. versionchanged:: 3.13
1173
+ Deprecated. Use ``client.options.pool_options.max_idle_time_seconds`` instead.
1160
1174
"""
1175
+ warnings .warn ("max_idle_time_ms is deprecated. Use ``client.options.pool_options.max_idle_time_seconds`` instead." , DeprecationWarning , stacklevel = 2 )
1161
1176
seconds = self .__options .pool_options .max_idle_time_seconds
1162
1177
if seconds is None :
1163
1178
return None
@@ -1177,6 +1192,17 @@ def nodes(self):
1177
1192
description = self ._topology .description
1178
1193
return frozenset (s .address for s in description .known_servers )
1179
1194
1195
+ @property
1196
+ def options (self ):
1197
+ """The configuration options for this client.
1198
+
1199
+ :Returns:
1200
+ An instance of :class:`~pymongo.client_options.ClientOptions`.
1201
+
1202
+ .. versionadded:: 3.13
1203
+ """
1204
+ return self .__options
1205
+
1180
1206
@property
1181
1207
def max_bson_size (self ):
1182
1208
"""The largest BSON object the connected server accepts in bytes.
@@ -1212,22 +1238,42 @@ def max_write_batch_size(self):
1212
1238
1213
1239
@property
1214
1240
def local_threshold_ms (self ):
1215
- """The local threshold for this instance."""
1241
+ """**DEPRECATED**: The local threshold for this instance.
1242
+
1243
+ .. versionchanged:: 3.13
1244
+ Deprecated. Use ``client.options.local_threshold_ms`` instead.
1245
+ """
1246
+ warnings .warn ("local_threshold_ms is deprecated. Use ``client.options.local_threshold_ms`` instead." , DeprecationWarning , stacklevel = 2 )
1216
1247
return self .__options .local_threshold_ms
1217
1248
1218
1249
@property
1219
1250
def server_selection_timeout (self ):
1220
- """The server selection timeout for this instance in seconds."""
1251
+ """**DEPRECATED**: The server selection timeout for this instance in seconds.
1252
+
1253
+ .. versionchanged:: 3.13
1254
+ Deprecated. Use ``client.options.server_selection_timeout`` instead.
1255
+ """
1256
+ warnings .warn ("server_selection_timeout is deprecated. Use ``client.options.server_selection_timeout`` instead." , DeprecationWarning , stacklevel = 2 )
1221
1257
return self .__options .server_selection_timeout
1222
1258
1223
1259
@property
1224
1260
def retry_writes (self ):
1225
- """If this instance should retry supported write operations."""
1261
+ """**DEPRECATED**: If this instance should retry supported write operations.
1262
+
1263
+ .. versionchanged:: 3.13
1264
+ Deprecated. Use ``client.options.retry_writes`` instead.
1265
+ """
1266
+ warnings .warn ("retry_writes is deprecated. Use ``client.options.retry_writes`` instead." , DeprecationWarning , stacklevel = 2 )
1226
1267
return self .__options .retry_writes
1227
1268
1228
1269
@property
1229
1270
def retry_reads (self ):
1230
- """If this instance should retry supported write operations."""
1271
+ """**DEPRECATED**: If this instance should retry supported write operations.
1272
+
1273
+ .. versionchanged:: 3.13
1274
+ Deprecated. Use ``client.options.retry_reads`` instead.
1275
+ """
1276
+ warnings .warn ("retry_reads is deprecated. Use ``client.options.retry_reads`` instead." , DeprecationWarning , stacklevel = 2 )
1231
1277
return self .__options .retry_reads
1232
1278
1233
1279
def _is_writable (self ):
@@ -1469,7 +1515,7 @@ def _retry_with_session(self, retryable, func, session, bulk):
1469
1515
1470
1516
Re-raises any exception thrown by func().
1471
1517
"""
1472
- retryable = retryable and self .retry_writes and session and not session .in_transaction
1518
+ retryable = retryable and self .options . retry_writes and session and not session .in_transaction
1473
1519
return self ._retry_internal (retryable , func , session , bulk )
1474
1520
1475
1521
def _retry_internal (self , retryable , func , session , bulk ):
@@ -1538,7 +1584,7 @@ def _retryable_read(self, func, read_pref, session, address=None, retryable=True
1538
1584
1539
1585
Re-raises any exception thrown by func().
1540
1586
"""
1541
- retryable = retryable and self .retry_reads and not (session and session .in_transaction )
1587
+ retryable = retryable and self .options . retry_reads and not (session and session .in_transaction )
1542
1588
last_error = None
1543
1589
retrying = False
1544
1590
0 commit comments