Skip to content

fix(shell): close database connections explicitly on exit - #356

Open
yjean wants to merge 1 commit into
Maxteabag:mainfrom
yjean:fix/close-connections-on-exit
Open

yjean wants to merge 1 commit into
Maxteabag:mainfrom
yjean:fix/close-connections-on-exit

Conversation

@yjean

@yjean yjean commented Nov 13, 2026

Copy link
Copy Markdown

Problem

Quitting sqlit while connected to Snowflake prints:

<sys>:0: FutureWarning: Connection was not explicitly closed before process exit. Auto-cleanup at exit will be disabled by default in a future version. Please explicitly call connection.close() or use context manager.

On exit the app shuts down the process worker but never closes the active ConnectionSession or the TransactionExecutor's persistent connection. Drivers fall back to their own atexit cleanup; snowflake-connector-python now warns about it and plans to drop that fallback.

Fix

on_unmount (runs on every exit path, not only action_quit) now closes the session and the transaction executor synchronously. _disconnect_silent isn't reused because it closes the session in a background worker and refreshes the UI, neither of which fits teardown.

Tests

  • New tests/ui/test_close_connections_on_exit.py: fails without the fix, passes with it.
  • pytest tests/unit tests/ui/test_light_theme_contrast.py tests/ui/test_close_connections_on_exit.py: 1321 passed, 3 skipped.
  • No new ruff findings (the 5 in main.py exist on main).

🤖 Generated with Claude Code

Quitting left the active session and the transaction executor's connection
open, so drivers fell back to their own atexit cleanup. snowflake-connector-python
now warns about that:

  FutureWarning: Connection was not explicitly closed before process exit.

Close both synchronously in on_unmount, which runs on every exit path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant