diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 73096eae..cacf589f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,7 @@ Bug Fixes * Avoid to replace a connection that is supposed to shutdown (PYTHON-772) * request_ids may not be returned to the pool (PYTHON-739) * Fix murmur3 on big-endian systems (PYTHON-653) +* Ensure unused connections are closed if a Session is deleted by the GC (PYTHON-774) Other ----- diff --git a/cassandra/cluster.py b/cassandra/cluster.py index cfe12f9c..b5a7336e 100644 --- a/cassandra/cluster.py +++ b/cassandra/cluster.py @@ -2325,6 +2325,10 @@ class Session(object): def __exit__(self, *args): self.shutdown() + def __del__(self): + # Ensure all connections are closed, in case the Session object is deleted by the GC + self.shutdown() + def add_or_renew_pool(self, host, is_host_addition): """ For internal use only.