From 1ca83aa8326a0fb935c42be18e781a851c952ec0 Mon Sep 17 00:00:00 2001 From: Alan Boudreault Date: Wed, 12 Jul 2017 06:44:05 -0400 Subject: [PATCH] Make sure the session is shutdown on destruction --- CHANGELOG.rst | 1 + cassandra/cluster.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e28afe80..cccdf873 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,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.