You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2023/04/13 12:17:54 UTC

[phoenix-queryserver] branch master updated: PHOENIX-6926 Do not throw exception when shutting down Python with open connections

This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix-queryserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 26a7c51  PHOENIX-6926 Do not throw exception when shutting down Python with open connections
26a7c51 is described below

commit 26a7c51a3547642ce654c4d2188853492a9381b6
Author: rbeauchemin3 <rb...@gatech.edu>
AuthorDate: Sun Dec 19 09:26:18 2021 -0500

    PHOENIX-6926 Do not throw exception when shutting down Python with open connections
---
 python-phoenixdb/NEWS.rst                | 1 +
 python-phoenixdb/phoenixdb/connection.py | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/python-phoenixdb/NEWS.rst b/python-phoenixdb/NEWS.rst
index 590a62f..59824c9 100644
--- a/python-phoenixdb/NEWS.rst
+++ b/python-phoenixdb/NEWS.rst
@@ -13,6 +13,7 @@ Unreleased
 - Replace deprecated failUnless methods in tests (PHOENIX-6892)
 - Add support for specifying custom HTTP headers (PHOENIX-6921)
 - Use JDBC/Avatica column label as column name when set (PHOENIX-6917)
+- Do not throw exception when shutting down Python with open connections (PHOENIX-6926)
 
 Version 1.2.1
 -------------
diff --git a/python-phoenixdb/phoenixdb/connection.py b/python-phoenixdb/phoenixdb/connection.py
index f752230..74cdbdc 100644
--- a/python-phoenixdb/phoenixdb/connection.py
+++ b/python-phoenixdb/phoenixdb/connection.py
@@ -56,8 +56,12 @@ class Connection(object):
         self.set_session(**avatica_props_init)
 
     def __del__(self):
-        if not self._closed:
-            self.close()
+        try:
+            if not self._closed:
+                self.close()
+        except ImportError:
+            # Pass if Python is shutting down when this is called
+            pass
 
     def __enter__(self):
         return self