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 , \
@@ -531,10 +528,10 @@ def append_conf(self, line='', filename=PG_CONF_FILE, **kwargs):
531
528
This instance of :class:`.PostgresNode`.
532
529
533
530
Examples:
534
- append_conf(fsync=False)
535
- append_conf('log_connections = yes')
536
- append_conf(random_page_cost=1.5, fsync=True, ...)
537
- append_conf('postgresql.conf', 'synchronous_commit = off')
531
+ >>> append_conf(fsync=False)
532
+ >>> append_conf('log_connections = yes')
533
+ >>> append_conf(random_page_cost=1.5, fsync=True, ...)
534
+ >>> append_conf('postgresql.conf', 'synchronous_commit = off')
538
535
"""
539
536
540
537
lines = [line ]
@@ -970,8 +967,7 @@ def poll_query_until(self,
970
967
sleep_time = 1 ,
971
968
expected = True ,
972
969
commit = True ,
973
- raise_programming_error = True ,
974
- raise_internal_error = True ):
970
+ suppress = None ):
975
971
"""
976
972
Run a query once per second until it returns 'expected'.
977
973
Query should return a single value (1 row, 1 column).
@@ -984,13 +980,13 @@ def poll_query_until(self,
984
980
sleep_time: how much should we sleep after a failure?
985
981
expected: what should be returned to break the cycle?
986
982
commit: should (possible) changes be committed?
987
- raise_programming_error: enable ProgrammingError?
988
- raise_internal_error: enable InternalError?
983
+ suppress: a collection of exceptions to be suppressed.
989
984
990
985
Examples:
991
- poll_query_until('select true')
992
- poll_query_until('postgres', "select now() > '01.01.2018'")
993
- poll_query_until('select false', expected=True, max_attempts=4)
986
+ >>> poll_query_until('select true')
987
+ >>> poll_query_until('postgres', "select now() > '01.01.2018'")
988
+ >>> poll_query_until('select false', expected=True, max_attempts=4)
989
+ >>> poll_query_until('select 1', suppress={testgres.OperationalError})
994
990
"""
995
991
996
992
# sanity checks
@@ -1022,13 +1018,8 @@ def poll_query_until(self,
1022
1018
elif expected is None :
1023
1019
return # done
1024
1020
1025
- except ProgrammingError as e :
1026
- if raise_programming_error :
1027
- raise e
1028
-
1029
- except InternalError as e :
1030
- if raise_internal_error :
1031
- raise e
1021
+ except tuple (suppress or []):
1022
+ pass # we're suppressing them
1032
1023
1033
1024
time .sleep (sleep_time )
1034
1025
attempts += 1
@@ -1219,13 +1210,14 @@ def pgbench_run(self, dbname=None, username=None, options=[], **kwargs):
1219
1210
options: additional options for pgbench (list).
1220
1211
1221
1212
**kwargs: named options for pgbench.
1222
- Examples:
1223
- pgbench_run(initialize=True, scale=2)
1224
- pgbench_run(time=10)
1225
1213
Run pgbench --help to learn more.
1226
1214
1227
1215
Returns:
1228
1216
Stdout produced by pgbench.
1217
+
1218
+ Examples:
1219
+ >>> pgbench_run(initialize=True, scale=2)
1220
+ >>> pgbench_run(time=10)
1229
1221
"""
1230
1222
1231
1223
# Set default arguments
0 commit comments