Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "noverde-serpens"
version = "2.8.0"
version = "2.8.1"
description = "A set of Python utilities, recipes and snippets"
readme = {file = "README.md", content-type = "text/markdown"}
authors = [
Expand Down
8 changes: 3 additions & 5 deletions serpens/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ def _on_connect(dbapi_conn, _):
idle_ms = int(os.getenv("DB_IDLE_IN_TX_TIMEOUT_MS", "10000"))
cur = dbapi_conn.cursor()
try:
cur.execute(
f"SET statement_timeout = {stmt_ms};"
f"SET lock_timeout = {lock_ms};"
f"SET idle_in_transaction_session_timeout = {idle_ms}"
)
cur.execute(f"SET statement_timeout = {stmt_ms}")
cur.execute(f"SET lock_timeout = {lock_ms}")
cur.execute(f"SET idle_in_transaction_session_timeout = {idle_ms}")
finally:
cur.close()

Expand Down
9 changes: 5 additions & 4 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ def test_executes_set_statements(self):
},
):
database._on_connect(conn, None)
called_sql = cur.execute.call_args.args[0]
self.assertIn("statement_timeout = 9000", called_sql)
self.assertIn("lock_timeout = 1500", called_sql)
self.assertIn("idle_in_transaction_session_timeout = 12000", called_sql)
executed = [c.args[0] for c in cur.execute.call_args_list]
self.assertEqual(len(executed), 3)
self.assertEqual(executed[0], "SET statement_timeout = 9000")
self.assertEqual(executed[1], "SET lock_timeout = 1500")
self.assertEqual(executed[2], "SET idle_in_transaction_session_timeout = 12000")
cur.close.assert_called_once()


Expand Down
Loading