postgresql-testing 0.0.2__tar.gz → 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: postgresql-testing
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: PostgreSQL testing helpers
5
5
  Author: Oli Russell
6
6
  Author-email: Oli Russell <mrxoliver@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "postgresql-testing"
3
- version = "0.0.2"
3
+ version = "0.0.3"
4
4
  description = "PostgreSQL testing helpers"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -116,8 +116,16 @@ def serve(c: ClusterConfig) -> Iterator[None]:
116
116
  _try_connect(c.superuser().dsn)
117
117
  yield
118
118
  finally:
119
+ # Stop any ongoing queries
120
+ with psycopg.connect(c.superuser().dsn) as conn, conn.cursor() as cur:
121
+ cur.execute("SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid()")
122
+ # Shutdown
119
123
  process.terminate()
120
- process.wait()
124
+ try:
125
+ process.wait(timeout=1)
126
+ except subprocess.TimeoutExpired:
127
+ process.kill()
128
+ process.wait(timeout=5)
121
129
 
122
130
 
123
131
  def ensure_user(c: DatabaseConfig) -> None: