Skip to content

Commit 9268a4b

Browse files
committed
shutdown cluster on cqlengine connection unregistration
1 parent 039cb78 commit 9268a4b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cassandra/cqlengine/connection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def handle_lazy_connect(self):
127127
# lazy_connect might have been set to False by another thread while waiting the lock
128128
# In this case, do nothing.
129129
if self.lazy_connect:
130-
log.debug(format_log_context("Lazy connect for connection", connection=self.name))
130+
log.debug(format_log_context("Lazy connect enabled", connection=self.name))
131131
self.lazy_connect = False
132132
self.setup()
133133

@@ -162,8 +162,11 @@ def unregister_connection(name):
162162
session = None
163163
log.warning("Unregistering default connection '{0}'. Use set_default_connection to set a new one.".format(name))
164164

165-
log.debug("Connection '{0}' has been removed from the registry.".format(name))
165+
conn = _connections[name]
166+
if conn.cluster:
167+
conn.cluster.shutdown()
166168
del _connections[name]
169+
log.debug("Connection '{0}' has been removed from the registry.".format(name))
167170

168171

169172
def set_default_connection(name):

0 commit comments

Comments
 (0)