Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: Robust resource cleanup of Connection/Cursor for graceful exit & add tests#128

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bewithgaurav merged 7 commits intomainfrombewithgaurav/conn_cursor_resource_cleanup
Jul 16, 2025

Conversation

bewithgaurav
Copy link
Collaborator

@bewithgauravbewithgaurav commentedJul 8, 2025
edited
Loading

ADO Work Item Reference

AB#37889
Github Issue -#131


Summary

This pull request introduces enhancements to cursor and connection management in themssql_python library, aiming to improve resource cleanup and debugging capabilities. Key changes include adding destructors for automatic cleanup, enhancing logging for better traceability, and introducing new tests to validate cursor behavior during garbage collection and connection closure.

Resource Cleanup Enhancements:

  • Added a__del__ method inmssql_python/connection.py to automatically close connections during object destruction, with error logging for cleanup issues.
  • Added a__del__ method inmssql_python/cursor.py to ensure cursors are closed when no longer needed, with error handling during destruction.

Debugging Improvements:

  • Enhanced logging inmssql_python/connection.py andmssql_python/cursor.py with detailed print statements for tracking cursor states and operations (e.g., during connection closure, statement execution, and data fetching).[1][2][3][4]

Testing Additions:

  • Introducedtest_cursor_cleanup_without_close to verify that cursors are properly cleaned up when the connection is not explicitly closed.
  • Addedtest_no_segfault_on_gc to ensure no segmentation faults occur during garbage collection of connections and cursors. This test runs in a subprocess to isolate potential crashes.

@github-actionsgithub-actionsbot added the pr-size: mediumModerate update size labelJul 8, 2025
@github-actionsgithub-actionsbot added pr-size: mediumModerate update size and removed pr-size: mediumModerate update size labelsJul 8, 2025
@github-actionsgithub-actionsbot added pr-size: mediumModerate update size and removed pr-size: mediumModerate update size labelsJul 8, 2025
@github-actionsgithub-actionsbot added pr-size: mediumModerate update size and removed pr-size: mediumModerate update size labelsJul 8, 2025
@github-actionsgithub-actionsbot added pr-size: mediumModerate update size and removed pr-size: mediumModerate update size labelsJul 10, 2025
jahnvi480
jahnvi480 previously approved these changesJul 16, 2025
@github-actionsgithub-actionsbot added pr-size: mediumModerate update size and removed pr-size: mediumModerate update size labelsJul 16, 2025
Copy link
Contributor

@gargsaumyagargsaumya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@bewithgauravbewithgaurav merged commit4116996 intomainJul 16, 2025
16 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jahnvi480jahnvi480jahnvi480 approved these changes

@gargsaumyagargsaumyagargsaumya approved these changes

Assignees
No one assigned
Labels
pr-size: mediumModerate update size
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Segfault while exiting when both cursor/connection are left unclosed
3 participants
@bewithgaurav@jahnvi480@gargsaumya

[8]ページ先頭

©2009-2025 Movatter.jp