FIX: Cursor resource management, error handling & logging#183
Merged
bewithgaurav merged 16 commits intomainfrom Sep 5, 2025
Merged
FIX: Cursor resource management, error handling & logging#183bewithgaurav merged 16 commits intomainfrom
bewithgaurav merged 16 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves cursor resource management and error handling in the mssql_python cursor module. The changes make cursor operations more robust by implementing idempotent close behavior and better cleanup procedures.
- Enhanced cursor close operation to be idempotent and use more specific exception types
- Fixed destructor to properly check the
closedattribute instead of_closed - Improved logging during cleanup by reducing error noise to debug level
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
bewithgaurav
commented
Aug 18, 2025
bewithgaurav
commented
Aug 18, 2025
sumitmsft
reviewed
Aug 24, 2025
sumitmsft
reviewed
Aug 24, 2025
sumitmsft
requested changes
Aug 24, 2025
Contributor
sumitmsft
left a comment
There was a problem hiding this comment.
Left a couple of comments.
… bewithgaurav/fix_cursor_cleanup_log
gargsaumya
approved these changes
Sep 5, 2025
sumitmsft
approved these changes
Sep 5, 2025
__del__
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request makes improvements to the cursor resource management and error handling in the
mssql_python/cursor.pymodule. The main changes include making the cursor close operation idempotent, refining exception types, and improving logging during cleanup. These updates help ensure more robust and predictable behavior when working with cursors.Error handling improvements:
Exceptionto a more specificProgrammingError, providing clearer feedback to users.ProgrammingErrorinstead ofInterfaceError, aligning with the new error handling approach.Resource cleanup and logging:
__del__) to check for the correctclosedattribute and made sure no exception is raised if the cursor is already closed, enhancing reliability during garbage collection.