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

kevinjqliu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 34265fb3 infra: cleanup filterwarnings (#2569)
34265fb3 is described below

commit 34265fb3978d34fbeb078413ba1408142b074eff
Author: Kevin Liu <[email protected]>
AuthorDate: Sat Oct 4 14:14:16 2025 -0700

    infra: cleanup filterwarnings (#2569)
    
    <!--
    Thanks for opening a pull request!
    -->
    
    <!-- In the case this PR will resolve an issue, please replace
    ${GITHUB_ISSUE_ID} below with the actual Github issue id. -->
    <!-- Closes #${GITHUB_ISSUE_ID} -->
    
    # Rationale for this change
    cleanup!
    
    ## Are these changes tested?
    
    ## Are there any user-facing changes?
    
    <!-- In the case of user-facing changes, please add the changelog label.
    -->
---
 pyiceberg/catalog/hive.py  | 5 +++++
 pyproject.toml             | 2 --
 tests/catalog/test_hive.py | 9 +++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/pyiceberg/catalog/hive.py b/pyiceberg/catalog/hive.py
index e558c8c3..93ece35c 100644
--- a/pyiceberg/catalog/hive.py
+++ b/pyiceberg/catalog/hive.py
@@ -185,6 +185,11 @@ class _HiveClient:
             try:
                 self._transport.open()
             except (TypeError, TTransport.TTransportException):
+                # Close the old transport before reinitializing to prevent 
resource leaks
+                try:
+                    self._transport.close()
+                except Exception:
+                    pass
                 # reinitialize _transport
                 self._transport = self._init_thrift_transport()
                 self._transport.open()
diff --git a/pyproject.toml b/pyproject.toml
index 1d948380..ba3b5e24 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -346,8 +346,6 @@ markers = [
 # Turns a warning into an error
 filterwarnings = [
   "error",
-  "ignore:A plugin raised an exception during an old-style hookwrapper 
teardown.",
-  "ignore:unclosed <socket.socket",
   # Remove this in a future release of PySpark.
   "ignore:distutils Version classes are deprecated. Use packaging.version 
instead.",
   # Remove this in a future release of PySpark. 
https://github.com/apache/iceberg-python/issues/1349
diff --git a/tests/catalog/test_hive.py b/tests/catalog/test_hive.py
index 2da3f99f..649e2545 100644
--- a/tests/catalog/test_hive.py
+++ b/tests/catalog/test_hive.py
@@ -204,6 +204,7 @@ class SaslServer(threading.Thread):
         self._response = response
         self._port = None
         self._port_bound = threading.Event()
+        self._clients: list[thrift.transport.TSocket.TSocket] = []  # Track 
accepted client connections
 
     def run(self) -> None:
         self._socket.listen()
@@ -222,6 +223,7 @@ class SaslServer(threading.Thread):
             try:
                 client = self._socket.accept()
                 if client:
+                    self._clients.append(client)  # Track the client
                     client.write(self._response)
                     client.flush()
             except Exception:
@@ -233,6 +235,12 @@ class SaslServer(threading.Thread):
         return self._port
 
     def close(self) -> None:
+        # Close all client connections first
+        for client in self._clients:
+            try:
+                client.close()
+            except Exception:
+                pass
         self._socket.close()
 
 
@@ -1392,6 +1400,7 @@ def 
test_create_hive_client_with_kerberos_using_context_manager(
         with client as open_client:
             assert open_client._iprot.trans.isOpen()
 
+        assert not open_client._iprot.trans.isOpen()
         # Use the context manager a second time to see if
         # closing and re-opening work as expected.
         with client as open_client:

Reply via email to