Forking a multi-threaded Python process is becoming more and more reliable in recent versions of Python. See
However a MongoClient is still not fork-safe (also neither is ObjectId because it contains a global lock): https://pymongo.readthedocs.io/en/stable/faq.html#is-pymongo-fork-safe
We should investigate if we can use os.register_at_fork (new in Python 3.7) to allow a MongoClient to be fork-safe.
For example, something like this could work:
The above change would make pymongo mostly fork-safe in Python 3.7+. I added the mostly caveat because the python interpreter itself still has some fork deadlock issues due to various locks in the standard library (see the above python bugs).