Skip to content

Conversation

@fcollman
Copy link
Collaborator

No description provided.

@fcollman fcollman requested a review from Copilot July 23, 2025 14:46
Copy link
Contributor

Copilot AI left a 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 session management by implementing session validation and reuse strategies to optimize database connection handling. The changes focus on preventing unnecessary session closures and adding validation to ensure sessions remain healthy before reuse.

  • Adds session validation logic to check connection health before reusing cached sessions
  • Modifies session lifecycle to prevent premature closure and enable session reuse
  • Introduces explicit session cleanup method for controlled shutdown scenarios

if not hasattr(session, 'bind') or session.bind is None:
return False
# Try a simple query to test the connection
session.execute("SELECT 1")
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

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

The session validation query should use session.execute(text("SELECT 1")) to properly handle the SQL string. SQLAlchemy 2.0+ requires explicit text() wrapper for raw SQL strings.

Copilot uses AI. Check for mistakes.
fcollman and others added 3 commits July 23, 2025 07:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@fcollman fcollman merged commit 72582c2 into master Jul 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants