Skip to content

Commit 8a25cb3

Browse files
authored
Add pgbench_with_wait function (#122)
1 parent 0cf30a7 commit 8a25cb3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Diff for: testgres/node.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ def pgbench(self,
13711371
username=None,
13721372
stdout=None,
13731373
stderr=None,
1374-
options=[]):
1374+
options=None):
13751375
"""
13761376
Spawn a pgbench process.
13771377
@@ -1385,6 +1385,8 @@ def pgbench(self,
13851385
Returns:
13861386
Process created by subprocess.Popen.
13871387
"""
1388+
if options is None:
1389+
options = []
13881390

13891391
# Set default arguments
13901392
dbname = dbname or default_dbname()
@@ -1404,6 +1406,29 @@ def pgbench(self,
14041406

14051407
return proc
14061408

1409+
def pgbench_with_wait(self,
1410+
dbname=None,
1411+
username=None,
1412+
stdout=None,
1413+
stderr=None,
1414+
options=None):
1415+
"""
1416+
Do pgbench command and wait.
1417+
1418+
Args:
1419+
dbname: database name to connect to.
1420+
username: database user name.
1421+
stdout: stdout file to be used by Popen.
1422+
stderr: stderr file to be used by Popen.
1423+
options: additional options for pgbench (list).
1424+
"""
1425+
if options is None:
1426+
options = []
1427+
1428+
with self.pgbench(dbname, username, stdout, stderr, options) as pgbench:
1429+
pgbench.wait()
1430+
return
1431+
14071432
def pgbench_init(self, **kwargs):
14081433
"""
14091434
Small wrapper for pgbench_run().

0 commit comments

Comments
 (0)