# `write_concern` – Tools for specifying write concern

Tools for working with write concerns.

See also

This module is compatible with both the synchronous and asynchronous PyMongo APIs.

class pymongo.write_concern.WriteConcern
  Parameters:

    - w (Optional[Union[int, str]]) – (integer or string) Used with replication, write operations will block until they have been replicated to the specified number or tagged set of servers. w=<integer> always includes the replica set primary (e.g. w=3 means write to the primary and wait until replicated to two secondaries). w=0 disables acknowledgement of write operations and can not be used with other write concern options.

    - wtimeout (Optional[int]) – (integer) DEPRECATED Used in conjunction with w. Specify a value in milliseconds to control how long to wait for write propagation to complete. If replication does not complete in the given timeframe, a timeout exception is raised.

    - j (Optional[bool]) – If `True` block until write operations have been committed to the journal. Cannot be used in combination with fsync. Write operations will fail with an exception if this option is used when the server is running without journaling.

    - fsync (Optional[bool]) – If `True` and the server is running without journaling, blocks until the server has synced all data files to disk. If the server is running with journaling, this acts the same as the j option, blocking until write operations have been committed to the journal. Cannot be used in combination with j.

  Changed in version 4.7: Deprecated parameter `wtimeout`, use `timeout()`.

  property acknowledged: bool

    If `True` write operations will wait for acknowledgement before returning.

  property document: dict[str, Any]

    The document representation of this write concern.

    Note

    `WriteConcern` is immutable. Mutating the value of `document` does not mutate this `WriteConcern`.

  property is_server_default: bool

    Does this WriteConcern match the server default.

pymongo.write_concern.validate_boolean(option, value)

  Validates that ‘value’ is True or False.

  Parameters:

    - option (str)

    - value (Any)

  Return type:

    bool