Skip to content

Commit 2df024f

Browse files
authored
PYTHON-3984 Deprecate WriteConcern.wtimeout in favor of pymongo.timeout() (#1591)
1 parent ff44267 commit 2df024f

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

doc/changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ PyMongo 4.7 brings a number of improvements including:
4343
creating vector search indexes in MongoDB Atlas.
4444
- Fixed a bug where ``read_concern`` and ``write_concern`` were improperly added to
4545
:meth:`~pymongo.collection.Collection.list_search_indexes` queries.
46-
46+
- Deprecated :attr:`pymongo.write_concern.WriteConcern.wtimeout` and :attr:`pymongo.mongo_client.MongoClient.wTimeoutMS`.
47+
Use :meth:`~pymongo.timeout` instead.
4748

4849
Unavoidable breaking changes
4950
............................

pymongo/mongo_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ def __init__(
439439
primary (e.g. w=3 means write to the primary and wait until
440440
replicated to **two** secondaries). Passing w=0 **disables write
441441
acknowledgement** and all other write concern options.
442-
- `wTimeoutMS`: (integer) Used in conjunction with `w`. Specify a value
443-
in milliseconds to control how long to wait for write propagation
442+
- `wTimeoutMS`: **DEPRECATED** (integer) Used in conjunction with `w`.
443+
Specify a value in milliseconds to control how long to wait for write propagation
444444
to complete. If replication does not complete in the given
445445
timeframe, a timeout exception is raised. Passing wTimeoutMS=0
446446
will cause **write operations to wait indefinitely**.
@@ -717,6 +717,9 @@ def __init__(
717717
Not::
718718
719719
client.__my_database__
720+
721+
.. versionchanged:: 4.7
722+
Deprecated parameter ``wTimeoutMS``, use :meth:`~pymongo.timeout`.
720723
"""
721724
doc_class = document_class or dict
722725
self.__init_kwargs: dict[str, Any] = {

pymongo/write_concern.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class WriteConcern:
3838
replicated to **two** secondaries). **w=0 disables acknowledgement
3939
of write operations and can not be used with other write concern
4040
options.**
41-
:param wtimeout: (integer) Used in conjunction with `w`. Specify a value
42-
in milliseconds to control how long to wait for write propagation
43-
to complete. If replication does not complete in the given
41+
:param wtimeout: (integer) **DEPRECATED** Used in conjunction with `w`.
42+
Specify a value in milliseconds to control how long to wait for write
43+
propagation to complete. If replication does not complete in the given
4444
timeframe, a timeout exception is raised.
4545
:param j: If ``True`` block until write operations have been committed
4646
to the journal. Cannot be used in combination with `fsync`. Write
@@ -51,6 +51,10 @@ class WriteConcern:
5151
server is running with journaling, this acts the same as the `j`
5252
option, blocking until write operations have been committed to the
5353
journal. Cannot be used in combination with `j`.
54+
55+
56+
.. versionchanged:: 4.7
57+
Deprecated parameter ``wtimeout``, use :meth:`~pymongo.timeout`.
5458
"""
5559

5660
__slots__ = ("__document", "__acknowledged", "__server_default")

0 commit comments

Comments
 (0)