mongodb/mongo-python-driver — pull request #141 by hensom (2012-09-12 19:33:34+00:00)
Title: Shutdown ReplicaSetConnection monitors on exit

pymongo 2.2.1 recently changed the way that ReplicaSetConnections are monitored. It deprecated the use of daemon threads on certain systems which implies that even simple scripts now need to manually track which connections are opened and ensure they are all properly closed before the interpreter can exit. Performing this additional tracking can in certain cases be a non-trivial change and if possible would be better handled by the driver if at all possible.

This patch adds for tracking which monitoring threads are running and properly shutting them down before the interpreter starts deconstruction. I believe this should handle most of the race conditions left around from leaving the daemon threads running in the first place.