Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1139

Document that PyMongo is not fork safe

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4
    • Affects Version/s: None
    • Component/s: Docs
    • None

      The existing FAQ entry for multiprocessing blames the problems reported in PYTHON-961 on the getaddrinfo lock, implying that the problem doesn't exist on platforms that don't require the lock, but that's not strictly true.

      PyMongo 3.x is not fork safe. The multi-threaded monitoring and shared topology state means that forking is never safe after MongoClient has started to connect because Python Locks are not fork safe. Even without the getaddrinfo lock, if any of PyMongo's Locks are held, or any other Lock used by python internally is held, PyMongo will still deadlock after a fork.

      Add a new FAQ entry, "Is PyMongo Fork Safe?", answer the question "No" with a detailed explanation, clean up the multiprocessing FAQ entry to remove the explanations (focus on only the use case), then link the two entries to one another.

            Assignee:
            luke.lovett Luke Lovett
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: