Skip to content

Commit f9b6218

Browse files
committed
improve doc
1 parent 61cf36e commit f9b6218

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mongoengine/connection.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,11 @@ def disconnect(alias=DEFAULT_CONNECTION_NAME):
248248

249249
connection = _connections.pop(alias, None)
250250
if connection:
251-
# Only close the client if we're removing the final reference.
252-
# Use 'is' instead of 'in' or '==' to ensure the clients are
253-
# the same instance.
251+
# MongoEngine may share the same MongoClient across multiple aliases
252+
# if connection settings are the same so we only close
253+
# the client if we're removing the final reference.
254+
# Important to use 'is' instead of '==' because clients connected to the same cluster
255+
# will compare equal even with different options
254256
if all(connection is not c for c in _connections.values()):
255257
connection.close()
256258

0 commit comments

Comments
 (0)