Skip to content

Commit c8db549

Browse files
docs(fix-2530): enhance close() method docstring with Python 3.13 guidance
Improve the SqlCatalog.close() docstring to: - Emphasize that close() must be called in test fixture teardowns - Explain Python 3.13+ ResourceWarning prevention - Document the SQLAlchemy connection pool lifecycle - Clarify importance for both test and production scenarios (blobfuse) - Add reference to issue apache#2530 This helps future contributors understand why proper connection cleanup is essential. Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent 7281f05 commit c8db549

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎pyiceberg/catalog/sql.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,9 +778,17 @@ def close(self) -> None:
778778
"""Close the catalog and release database connections.
779779
780780
This method closes the SQLAlchemy engine and disposes of all connection pools.
781-
This ensures that any cached connections are properly closed, which is especially
782-
important for blobfuse scenarios where file handles need to be closed for
783-
data to be flushed to persistent storage.
781+
This is crucial for proper resource cleanup and must be called in test fixture
782+
teardowns to prevent Python 3.13+ ResourceWarnings about unclosed connections.
783+
784+
The connection pool lifecycle is managed by SQLAlchemy's engine. When dispose()
785+
is called, it closes all idle connections and invalidates active ones. This is
786+
especially important in test environments where fixtures create catalogs that
787+
otherwise may not be explicitly closed, and in production scenarios with
788+
blobfuse where file handles need to be closed for data to be flushed to
789+
persistent storage.
790+
791+
See: Issue #2530 (https://github.com/apache/iceberg-python/issues/2530)
784792
"""
785793
if hasattr(self, "engine"):
786794
self.engine.dispose()

0 commit comments

Comments
 (0)