Skip to content
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

feat: clear session pool on connection close #543

Merged
merged 5 commits into from Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions google/cloud/spanner_dbapi/connection.py
Expand Up @@ -235,6 +235,7 @@ def close(self):
):
self._transaction.rollback()

self.database._pool.clear()
IlyaFaer marked this conversation as resolved.
Show resolved Hide resolved
self.is_closed = True

def commit(self):
Expand Down
8 changes: 8 additions & 0 deletions tests/spanner_dbapi/test_connection.py
Expand Up @@ -77,3 +77,11 @@ def test_instance_property(self):

with self.assertRaises(AttributeError):
connection.instance = None

def test_clearing_pool_on_close(self):
connection = self._make_connection()
with mock.patch.object(
connection.database._pool, "clear"
) as pool_clear_mock:
connection.close()
pool_clear_mock.assert_called_once()