diff --git a/testgres/connection.py b/testgres/connection.py index 3943a4e2..b6d341e5 100644 --- a/testgres/connection.py +++ b/testgres/connection.py @@ -20,6 +20,7 @@ # export these exceptions InternalError = pglib.InternalError ProgrammingError = pglib.ProgrammingError +OperationalError = pglib.OperationalError class NodeConnection(object): diff --git a/testgres/node.py b/testgres/node.py index b171d965..39a706f0 100644 --- a/testgres/node.py +++ b/testgres/node.py @@ -22,7 +22,8 @@ from .connection import \ NodeConnection, \ InternalError, \ - ProgrammingError + ProgrammingError, \ + OperationalError from .consts import \ DATA_DIR, \ @@ -981,7 +982,8 @@ def poll_query_until(self, expected=True, commit=True, raise_programming_error=True, - raise_internal_error=True): + raise_internal_error=True, + raise_operational_error=True): """ Run a query once per second until it returns 'expected'. Query should return a single value (1 row, 1 column). @@ -1040,6 +1042,10 @@ def poll_query_until(self, if raise_internal_error: raise e + except OperationalError as e: + if raise_operational_error: + raise e + time.sleep(sleep_time) attempts += 1