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

Spawning mongocryptd leads to ResourceWarning: subprocess XXX is still running

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.10
    • Affects Version/s: 3.9
    • Component/s: Encryption
    • None

      The way we spawn mongocryptd leads to these warnings:

      $ python setup.py test -s test.test_encryption
      ...
      test_01_insert_succeeds_under_2MiB (test.test_encryption.TestBsonSizeBatches) ... /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py:858: ResourceWarning: subprocess 3521 is still running
        ResourceWarning, source=self)
      

      The issue is that we discard the Popen object will the daemon process is still running. I think we can fix this in a few ways:
      1) we can keep a reference to the Popen object and call wait() when closing a MongoClient.
      2) We can use the double-fork pattern to spawn mongocryptd as an actual daemon process.

      I think we should do option 2) because option 1) would only fix the issue for applications that call MongoClient.close() explicitly.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: