Skip to content

Commit 89f65a1

Browse files
committed
comments
1 parent e9f2992 commit 89f65a1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

mssql_python/connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def close(self) -> None:
233233
# Convert to list to avoid modification during iteration
234234
cursors_to_close = list(self._cursors)
235235
close_errors = []
236+
236237
for cursor in cursors_to_close:
237238
try:
238239
if not cursor.closed:
@@ -268,6 +269,11 @@ def close(self) -> None:
268269
logger.info("Connection closed successfully.")
269270

270271
def __del__(self):
272+
"""
273+
Destructor to ensure the connection is closed when the connection object is no longer needed.
274+
This is a safety net to ensure resources are cleaned up
275+
even if close() was not called explicitly.
276+
"""
271277
if not self._closed:
272278
try:
273279
self.close()

mssql_python/cursor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ def nextset(self) -> Union[bool, None]:
744744
def __del__(self):
745745
"""
746746
Destructor to ensure the cursor is closed when it is no longer needed.
747+
This is a safety net to ensure resources are cleaned up
748+
even if close() was not called explicitly.
747749
"""
748750
if not self.closed:
749751
try:

0 commit comments

Comments
 (0)