1919
2020from .config import testgres_config
2121
22- from .connection import \
23- NodeConnection , \
24- InternalError , \
25- ProgrammingError
22+ from .connection import NodeConnection
2623
2724from .consts import \
2825 DATA_DIR , \
@@ -541,10 +538,10 @@ def append_conf(self, line='', filename=PG_CONF_FILE, **kwargs):
541538 This instance of :class:`.PostgresNode`.
542539
543540 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')
548545 """
549546
550547 lines = [line ]
@@ -980,8 +977,7 @@ def poll_query_until(self,
980977 sleep_time = 1 ,
981978 expected = True ,
982979 commit = True ,
983- raise_programming_error = True ,
984- raise_internal_error = True ):
980+ suppress = None ):
985981 """
986982 Run a query once per second until it returns 'expected'.
987983 Query should return a single value (1 row, 1 column).
@@ -994,13 +990,13 @@ def poll_query_until(self,
994990 sleep_time: how much should we sleep after a failure?
995991 expected: what should be returned to break the cycle?
996992 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.
999994
1000995 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})
10041000 """
10051001
10061002 # sanity checks
@@ -1032,13 +1028,8 @@ def poll_query_until(self,
10321028 elif expected is None :
10331029 return # done
10341030
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
10421033
10431034 time .sleep (sleep_time )
10441035 attempts += 1
@@ -1229,13 +1220,14 @@ def pgbench_run(self, dbname=None, username=None, options=[], **kwargs):
12291220 options: additional options for pgbench (list).
12301221
12311222 **kwargs: named options for pgbench.
1232- Examples:
1233- pgbench_run(initialize=True, scale=2)
1234- pgbench_run(time=10)
12351223 Run pgbench --help to learn more.
12361224
12371225 Returns:
12381226 Stdout produced by pgbench.
1227+
1228+ Examples:
1229+ >>> pgbench_run(initialize=True, scale=2)
1230+ >>> pgbench_run(time=10)
12391231 """
12401232
12411233 # Set default arguments
0 commit comments