19
19
20
20
from .config import testgres_config
21
21
22
- from .connection import \
23
- NodeConnection , \
24
- InternalError , \
25
- ProgrammingError
22
+ from .connection import NodeConnection
26
23
27
24
from .consts import \
28
25
DATA_DIR , \
@@ -541,10 +538,10 @@ def append_conf(self, line='', filename=PG_CONF_FILE, **kwargs):
541
538
This instance of :class:`.PostgresNode`.
542
539
543
540
Examples:
544
- append_conf(fsync=False)
545
- append_conf('log_connections = yes')
546
- append_conf(random_page_cost=1.5, fsync=True, ...)
547
- append_conf('postgresql.conf', 'synchronous_commit = off')
541
+ >>> append_conf(fsync=False)
542
+ >>> append_conf('log_connections = yes')
543
+ >>> append_conf(random_page_cost=1.5, fsync=True, ...)
544
+ >>> append_conf('postgresql.conf', 'synchronous_commit = off')
548
545
"""
549
546
550
547
lines = [line ]
@@ -980,8 +977,7 @@ def poll_query_until(self,
980
977
sleep_time = 1 ,
981
978
expected = True ,
982
979
commit = True ,
983
- raise_programming_error = True ,
984
- raise_internal_error = True ):
980
+ suppress = None ):
985
981
"""
986
982
Run a query once per second until it returns 'expected'.
987
983
Query should return a single value (1 row, 1 column).
@@ -994,13 +990,13 @@ def poll_query_until(self,
994
990
sleep_time: how much should we sleep after a failure?
995
991
expected: what should be returned to break the cycle?
996
992
commit: should (possible) changes be committed?
997
- raise_programming_error: enable ProgrammingError?
998
- raise_internal_error: enable InternalError?
993
+ suppress: a collection of exceptions to be suppressed.
999
994
1000
995
Examples:
1001
- poll_query_until('select true')
1002
- poll_query_until('postgres', "select now() > '01.01.2018'")
1003
- poll_query_until('select false', expected=True, max_attempts=4)
996
+ >>> poll_query_until('select true')
997
+ >>> poll_query_until('postgres', "select now() > '01.01.2018'")
998
+ >>> poll_query_until('select false', expected=True, max_attempts=4)
999
+ >>> poll_query_until('select 1', suppress={testgres.OperationalError})
1004
1000
"""
1005
1001
1006
1002
# sanity checks
@@ -1032,13 +1028,8 @@ def poll_query_until(self,
1032
1028
elif expected is None :
1033
1029
return # done
1034
1030
1035
- except ProgrammingError as e :
1036
- if raise_programming_error :
1037
- raise e
1038
-
1039
- except InternalError as e :
1040
- if raise_internal_error :
1041
- raise e
1031
+ except tuple (suppress or []):
1032
+ pass # we're suppressing them
1042
1033
1043
1034
time .sleep (sleep_time )
1044
1035
attempts += 1
@@ -1229,13 +1220,14 @@ def pgbench_run(self, dbname=None, username=None, options=[], **kwargs):
1229
1220
options: additional options for pgbench (list).
1230
1221
1231
1222
**kwargs: named options for pgbench.
1232
- Examples:
1233
- pgbench_run(initialize=True, scale=2)
1234
- pgbench_run(time=10)
1235
1223
Run pgbench --help to learn more.
1236
1224
1237
1225
Returns:
1238
1226
Stdout produced by pgbench.
1227
+
1228
+ Examples:
1229
+ >>> pgbench_run(initialize=True, scale=2)
1230
+ >>> pgbench_run(time=10)
1239
1231
"""
1240
1232
1241
1233
# Set default arguments
0 commit comments