Skip to content

Commit 13b6530

Browse files
fix: move conn.release_resources() to close method (#1078)
1 parent 5806f94 commit 13b6530

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

aws_advanced_python_wrapper/wrapper.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def connect(
178178
def close(self) -> None:
179179
self._plugin_manager.execute(self.target_connection, DbApiMethod.CONNECTION_CLOSE,
180180
lambda: self.target_connection.close())
181+
self.release_resources()
181182

182183
def cursor(self, *args: Any, **kwargs: Any) -> AwsWrapperCursor:
183184
_cursor = self._plugin_manager.execute(self.target_connection, DbApiMethod.CONNECTION_CURSOR,
@@ -222,15 +223,13 @@ def release_resources(self):
222223
def _unwrap(self, unwrap_class: Type[UnwrapType]) -> Optional[UnwrapType]:
223224
return self._plugin_manager._unwrap(unwrap_class)
224225

225-
def __del__(self):
226-
self.release_resources()
227-
228226
def __enter__(self: AwsWrapperConnection) -> AwsWrapperConnection:
229227
return self
230228

231229
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
232230
self._plugin_manager.execute(self.target_connection, DbApiMethod.CONNECTION_CLOSE,
233231
lambda: self.target_connection.close(), exc_type, exc_val, exc_tb)
232+
self.release_resources()
234233

235234

236235
class AwsWrapperCursor(Cursor):

0 commit comments

Comments
 (0)