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

MongoReplicaSetClient should have a proper way to recreate monitors

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7
    • Affects Version/s: 2.5.2
    • Component/s: None
    • Labels:
    • Fully Compatible

      MongoReplicaSetClient uses a MonitorThread to monitor the health of the replica set members. In certain situations, this monitor thread needs to be recreated. Specifically, when using Celery, it clones the main process for each worker, resulting in a situation where the MonitorThread is there, but no longer alive.

      The proper way to handle this situation in Celery is to listen to a worker_process_init signal and re-spawn the thread. However, the MongoReplicaSetClient provides no way of re-spawning the threads without using internal members.

      There should be a simple way of re-spawning these monitors.

      If you want to be super-nice to the community (and Celery is really really popular), you would wire the MongoReplicaSetClient to the Celery worker_process_init signal and re- spawn it yourself, ignoring any ImportErrors for those who do not use Celery, or adding a configurable option to do so. I'd be happy to provide pull requests for either option. LMK if you're interested.

            jesse@mongodb.com A. Jesse Jiryu Davis
            zvikico Zviki Cohen
            0 Vote for this issue
            3 Start watching this issue