Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FUSE SUPPORT#184

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
demonolock merged 5 commits intomasterfromfuse-helpers
Mar 19, 2025
Merged
Changes fromall 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
43 changes: 37 additions & 6 deletionstestgres/plugins/pg_probackup2/pg_probackup2/app.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,6 +45,7 @@ class ProbackupApp:

def __init__(self, test_class: unittest.TestCase,
pg_node, pb_log_path, test_env, auto_compress_alg, backup_dir, probackup_path=None):
self.process = None
self.test_class = test_class
self.pg_node = pg_node
self.pb_log_path = pb_log_path
Expand All@@ -60,8 +61,35 @@ def __init__(self, test_class: unittest.TestCase,
self.test_class.output = None
self.execution_time = None

def form_daemon_process(self, cmdline, env):
def stream_output(stream: subprocess.PIPE) -> None:
try:
for line in iter(stream.readline, ''):
print(line)
self.test_class.output += line
finally:
stream.close()

self.process = subprocess.Popen(
cmdline,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
env=env
)
logging.info(f"Process started in background with PID: {self.process.pid}")

if self.process.stdout and self.process.stderr:
stdout_thread = threading.Thread(target=stream_output, args=(self.process.stdout,), daemon=True)
stderr_thread = threading.Thread(target=stream_output, args=(self.process.stderr,), daemon=True)

stdout_thread.start()
stderr_thread.start()

return self.process.pid

def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
skip_log_directory=False, expect_error=False, use_backup_dir=True):
skip_log_directory=False, expect_error=False, use_backup_dir=True, daemonize=False):
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Это будет раз на команду задаваться или на весь тестовый прогон?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Раз на команду, нужно для того чтобы мочь запустить команду в фоновом режиме. В моем случае чтобы запустить пробэкап с опцией fuse в фоне.

Run pg_probackup
backup_dir: target directory for making backup
Expand DownExpand Up@@ -118,11 +146,14 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
logging.warning("pg_probackup gdb suspended, waiting gdb connection on localhost:{0}".format(gdb_port))

start_time = time.time()
self.test_class.output = subprocess.check_output(
cmdline,
stderr=subprocess.STDOUT,
env=env
).decode('utf-8', errors='replace')
if daemonize:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

часть в daemonize можно вынести в функцию например такую form_daemon_process

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Сделаю, разумно

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Поправлено

return self.form_daemon_process(cmdline, env)
else:
self.test_class.output = subprocess.check_output(
cmdline,
stderr=subprocess.STDOUT,
env=env
).decode('utf-8', errors='replace')
end_time = time.time()
self.execution_time = end_time - start_time

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp