Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

operational error handling in poll_query_until() #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions testgres/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# export these exceptions
InternalError = pglib.InternalError
ProgrammingError = pglib.ProgrammingError
OperationalError = pglib.OperationalError


class NodeConnection(object):
Expand Down
10 changes: 8 additions & 2 deletions testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from .connection import \
NodeConnection, \
InternalError, \
ProgrammingError
ProgrammingError, \
OperationalError

from .consts import \
DATA_DIR, \
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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

Expand Down