-
Notifications
You must be signed in to change notification settings - Fork 27
FIX: Cursor resource management, error handling & logging #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
sumitmsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments.
… bewithgaurav/fix_cursor_cleanup_log
__del__
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.