@@ -14,15 +14,21 @@ for threaded applications.
14
14
Is PyMongo fork-safe?
15
15
---------------------
16
16
17
- PyMongo is not fork-safe. Care must be taken when using instances of
18
- :class: `~pymongo.mongo_client.MongoClient ` with ``fork() ``. Specifically,
19
- instances of MongoClient must not be copied from a parent process to
20
- a child process. Instead, the parent process and each child process must
21
- create their own instances of MongoClient. Instances of MongoClient copied from
22
- the parent process have a high probability of deadlock in the child process due
23
- to the inherent incompatibilities between ``fork() ``, threads, and locks
24
- described :ref: `below <pymongo-fork-safe-details >`. PyMongo will attempt to
25
- issue a warning if there is a chance of this deadlock occurring.
17
+ Starting in PyMongo 4.3, forking on a compatible Python interpreter while
18
+ using a client will result in all locks held by :class: `~bson.objectid
19
+ .ObjectId ` and :class: `~pymongo.mongo_client.MongoClient ` being released in
20
+ the child, as well as state shared between child and parent processes being
21
+ reset.
22
+
23
+ If greenlet has been imported (usually with a library like gevent or
24
+ Eventlet), care must be taken when using instances of :class: `~pymongo
25
+ .mongo_client.MongoClient ` with ``fork() ``. Specifically, instances of
26
+ MongoClient must not be copied from a parent process to a child process.
27
+ Instead, the parent process and each child process must create their own
28
+ instances of MongoClient. Instances of MongoClient copied from the parent
29
+ process have a high probability of deadlock in the child process due to the
30
+ inherent incompatibilities between ``fork() ``, threads, and locks described
31
+ :ref: `below<pymongo-fork-safe-details> `.
26
32
27
33
.. _pymongo-fork-safe-details :
28
34
0 commit comments