MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / TransactionOptions

Class TransactionOptions

pymongo/synchronous/client_session.py:273–362  ·  view source on GitHub ↗

Options for :meth:`ClientSession.start_transaction`. :param read_concern: The :class:`~pymongo.read_concern.ReadConcern` to use for this transaction. If ``None`` (the default) the :attr:`read_preference` of the :class:`MongoClient` is used. :param write_concern: The

Source from the content-addressed store, hash-verified

271
272
273class TransactionOptions:
274 """Options for :meth:`ClientSession.start_transaction`.
275
276 :param read_concern: The
277 :class:`~pymongo.read_concern.ReadConcern` to use for this transaction.
278 If ``None`` (the default) the :attr:`read_preference` of
279 the :class:`MongoClient` is used.
280 :param write_concern: The
281 :class:`~pymongo.write_concern.WriteConcern` to use for this
282 transaction. If ``None`` (the default) the :attr:`read_preference` of
283 the :class:`MongoClient` is used.
284 :param read_preference: The read preference to use. If
285 ``None`` (the default) the :attr:`read_preference` of this
286 :class:`MongoClient` is used. See :mod:`~pymongo.read_preferences`
287 for options. Transactions which read must use
288 :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`.
289 :param max_commit_time_ms: The maximum amount of time to allow a
290 single commitTransaction command to run. This option is an alias for
291 maxTimeMS option on the commitTransaction command. If ``None`` (the
292 default) maxTimeMS is not used.
293
294 .. versionchanged:: 3.9
295 Added the ``max_commit_time_ms`` option.
296
297 .. versionadded:: 3.7
298 """
299
300 def __init__(
301 self,
302 read_concern: Optional[ReadConcern] = None,
303 write_concern: Optional[WriteConcern] = None,
304 read_preference: Optional[_ServerMode] = None,
305 max_commit_time_ms: Optional[int] = None,
306 ) -> None:
307 self._read_concern = read_concern
308 self._write_concern = write_concern
309 self._read_preference = read_preference
310 self._max_commit_time_ms = max_commit_time_ms
311 if read_concern is not None:
312 if not isinstance(read_concern, ReadConcern):
313 raise TypeError(
314 "read_concern must be an instance of "
315 f"pymongo.read_concern.ReadConcern, not: {read_concern!r}"
316 )
317 if write_concern is not None:
318 if not isinstance(write_concern, WriteConcern):
319 raise TypeError(
320 "write_concern must be an instance of "
321 f"pymongo.write_concern.WriteConcern, not: {write_concern!r}"
322 )
323 if not write_concern.acknowledged:
324 raise ConfigurationError(
325 "transactions do not support unacknowledged write concern"
326 f": {write_concern!r}"
327 )
328 if read_preference is not None:
329 if not isinstance(read_preference, _ServerMode):
330 raise TypeError(

Callers 5

_create_entityMethod · 0.90
_create_entityMethod · 0.90
start_transactionMethod · 0.70

Calls

no outgoing calls