From ff3a8e448a2cf7ef299acf7e0cbc25bee9bb06d6 Mon Sep 17 00:00:00 2001 From: Favian Samatha Date: Fri, 16 Jan 2026 14:38:02 -0800 Subject: [PATCH] fix: move conn.release_resources() to close method --- aws_advanced_python_wrapper/wrapper.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aws_advanced_python_wrapper/wrapper.py b/aws_advanced_python_wrapper/wrapper.py index 7cfac6b8..111c87e2 100644 --- a/aws_advanced_python_wrapper/wrapper.py +++ b/aws_advanced_python_wrapper/wrapper.py @@ -178,6 +178,7 @@ def connect( def close(self) -> None: self._plugin_manager.execute(self.target_connection, DbApiMethod.CONNECTION_CLOSE, lambda: self.target_connection.close()) + self.release_resources() def cursor(self, *args: Any, **kwargs: Any) -> AwsWrapperCursor: _cursor = self._plugin_manager.execute(self.target_connection, DbApiMethod.CONNECTION_CURSOR, @@ -222,15 +223,13 @@ def release_resources(self): def _unwrap(self, unwrap_class: Type[UnwrapType]) -> Optional[UnwrapType]: return self._plugin_manager._unwrap(unwrap_class) - def __del__(self): - self.release_resources() - def __enter__(self: AwsWrapperConnection) -> AwsWrapperConnection: return self def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: self._plugin_manager.execute(self.target_connection, DbApiMethod.CONNECTION_CLOSE, lambda: self.target_connection.close(), exc_type, exc_val, exc_tb) + self.release_resources() class AwsWrapperCursor(Cursor):