Skip to content

Commit d7afaad

Browse files
committed
allow zero (infinite) 'max_attempts' in poll_query_until()
1 parent 15ccedb commit d7afaad

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

testgres/testgres.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,20 +922,25 @@ def poll_query_until(self,
922922
raise_internal_error=True):
923923
"""
924924
Run a query once a second until it returs 'expected'.
925+
Query should return single column.
925926
926927
Args:
927928
dbname: database name to connect to.
928929
query: query to be executed.
929930
username: database user name.
930-
max_attempts: how many times should we try?
931-
sleep_time: how long should we sleep after a failure?
931+
max_attempts: how many times should we try? 0 == infinite
932+
sleep_time: how much should we sleep after a failure?
932933
expected: what should be returned to break the cycle?
933934
raise_programming_error: mute ProgrammingError?
934935
raise_internal_error: mute InternalError?
935936
"""
936937

938+
# sanity checks
939+
assert(max_attempts >= 0)
940+
assert(sleep_time > 0)
941+
937942
attempts = 0
938-
while attempts < max_attempts:
943+
while max_attempts == 0 or attempts < max_attempts:
939944
try:
940945
res = self.execute(dbname=dbname,
941946
query=query,
@@ -1010,7 +1015,7 @@ def replicate(self, name, username=None,
10101015
xlog_method=DEFAULT_XLOG_METHOD,
10111016
use_logging=False):
10121017
"""
1013-
Create a replica of this node.
1018+
Create a binary replica of this node.
10141019
10151020
Args:
10161021
name: replica's name.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy