@@ -336,7 +336,17 @@ def _within_time_limit(start_time):
336
336
337
337
338
338
class ClientSession (object ):
339
- """A session for ordering sequential operations."""
339
+ """A session for ordering sequential operations.
340
+
341
+ :class:`ClientSession` instances are **not thread-safe or fork-safe**.
342
+ They can only be used by one thread or process at a time. A single
343
+ :class:`ClientSession` cannot be used to run multiple operations
344
+ concurrently.
345
+
346
+ Should not be initialized directly by application developers - to create a
347
+ :class:`ClientSession`, call
348
+ :meth:`~pymongo.mongo_client.MongoClient.start_session`.
349
+ """
340
350
def __init__ (self , client , server_session , options , authset , implicit ):
341
351
# A MongoClient, a _ServerSession, a SessionOptions, and a set.
342
352
self ._client = client
@@ -461,6 +471,10 @@ def callback(session, custom_arg, custom_kwarg=None):
461
471
however, ``with_transaction`` will return without taking further
462
472
action.
463
473
474
+ :class:`ClientSession` instances are **not thread-safe or fork-safe**.
475
+ Consequently, the ``callback`` must not attempt to execute multiple
476
+ operations concurrently.
477
+
464
478
When ``callback`` raises an exception, ``with_transaction``
465
479
automatically aborts the current transaction. When ``callback`` or
466
480
:meth:`~ClientSession.commit_transaction` raises an exception that
0 commit comments