Skip to content

Remove polling #137

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

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Normalize error
  • Loading branch information
vshepard committed Jul 4, 2024
commit 0784f4961c335042d4bfdd3ea1626ae3b692a705
2 changes: 1 addition & 1 deletion testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,6 @@ def poll_query_until(self,
assert sleep_time > 0
attempts = 0
while max_attempts == 0 or attempts < max_attempts:
logging.info(f"Pooling {attempts}")
try:
res = self.execute(dbname=dbname,
query=query,
Expand All @@ -1189,6 +1188,7 @@ def poll_query_until(self,
return # done

except tuple(suppress or []):
logging.info(f"Trying execute, attempt {attempts + 1}.\nQuery: {query}")
pass # we're suppressing them

time.sleep(sleep_time)
Expand Down
10 changes: 9 additions & 1 deletion testgres/operations/remote_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
if not error:
error_found = 0
else:
error = normalize_error(error)
error_found = exit_status != 0 or any(
marker in error for marker in [b'error', b'Permission denied', b'fatal', b'No such file or directory'])
marker in error for marker in ['error', 'Permission denied', 'fatal', 'No such file or directory']
)

if error_found:
if isinstance(error, bytes):
Expand Down Expand Up @@ -369,3 +371,9 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
password=password,
)
return conn


def normalize_error(error):
if isinstance(error, bytes):
return error.decode()
return error
3 changes: 1 addition & 2 deletions testgres/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import division
from __future__ import print_function

import logging
import os

import sys
Expand Down Expand Up @@ -229,7 +228,7 @@ def eprint(*args, **kwargs):
"""
Print stuff to stderr.
"""
logging.error(*args, **kwargs)
print(*args, file=sys.stderr, **kwargs)


def options_string(separator=u" ", **kwargs):
Expand Down