-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
Topology.close() calls self._update_servers() which will open new Monitor threads and connection pools for servers that are in the topology description but not in the self.servers dict: https://github.com/mongodb/mongo-python-driver/blob/3.8.0/pymongo/topology.py#L399
A simple repro is creating a client with connect=False and then calling close:
>>> client = MongoClient(connect=False) >>> client._topology._servers {} >>> client.close() >>> client._topology._servers {('localhost', 27017): <pymongo.server.Server object at 0x10bd10e80>} >>> client._topology._servers[('localhost', 27017)]._monitor._executor._thread <weakproxy at 0x10bd35098 to Thread at 0x10bd10e48>
I think the simple fix is to remove the call to self._update_servers().
- is related to
-
PYTHON-1896 MongoClient hangs for 0.5 seconds on script exit
- Closed