File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -248,9 +248,11 @@ def disconnect(alias=DEFAULT_CONNECTION_NAME):
248
248
249
249
connection = _connections .pop (alias , None )
250
250
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
254
256
if all (connection is not c for c in _connections .values ()):
255
257
connection .close ()
256
258
You can’t perform that action at this time.
0 commit comments