-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Each MongoClient starts a thread to manage some of the client's resources (killing server cursors and maintaining the connection pool). This thread is named "pymongo_kill_cursors_thread" but it is only stopped after the client instance is garbage collected.
This causes behavior described in https://github.com/mongodb/motor/pull/44. If we stopped the "pymongo_kill_cursors_thread" when a MongoClient is closed then the thread would be destroyed without the need for garbage collection. This also brings the kill cursors thread's lifetime more in line with the Topology's lifetime.
I tested this theory using https://github.com/tjensen/motor-test-example and this pymongo branch and threads peeked around ~30 and remained stable for the entire nosetests run. Before the change I saw the number of threads climb to over 1300+.
Note we'll need to be sure that the kill cursors thread is restarted if the client is reused after being closed.
- is related to
-
PYTHON-2284 Delay starting pymongo_kill_cursors_thread when connect=False
- Closed