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

Commite63371a

Browse files
author
Stepan Neretin
committed
probackup plugin fixes
1 parentb7595ad commite63371a

File tree

1 file changed

+28
-23
lines changed
  • testgres/plugins/pg_probackup2/pg_probackup2

1 file changed

+28
-23
lines changed

‎testgres/plugins/pg_probackup2/pg_probackup2/app.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ def __init__(self, test_class: unittest.TestCase,
6161
self.test_class.output=None
6262
self.execution_time=None
6363

64+
defform_daemon_process(self,cmdline,env):
65+
defstream_output(stream:subprocess.PIPE)->None:
66+
try:
67+
forlineiniter(stream.readline,''):
68+
print(line)
69+
self.test_class.output+=line
70+
finally:
71+
stream.close()
72+
73+
self.process=subprocess.Popen(
74+
cmdline,
75+
stdout=subprocess.PIPE,
76+
stderr=subprocess.PIPE,
77+
text=True,
78+
env=env
79+
)
80+
logging.info(f"Process started in background with PID:{self.process.pid}")
81+
82+
ifself.process.stdoutandself.process.stderr:
83+
stdout_thread=threading.Thread(target=stream_output,args=(self.process.stdout,),daemon=True)
84+
stderr_thread=threading.Thread(target=stream_output,args=(self.process.stderr,),daemon=True)
85+
86+
stdout_thread.start()
87+
stderr_thread.start()
88+
89+
returnself.process.pid
90+
6491
defrun(self,command,gdb=False,old_binary=False,return_id=True,env=None,
6592
skip_log_directory=False,expect_error=False,use_backup_dir=True,daemonize=False):
6693
"""
@@ -120,29 +147,7 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
120147

121148
start_time=time.time()
122149
ifdaemonize:
123-
124-
defstream_output(stream:subprocess.PIPE)->None:
125-
forlineiniter(stream.readline,''):
126-
print(line)
127-
self.test_class.output+=line
128-
stream.close()
129-
130-
self.process=subprocess.Popen(
131-
cmdline,
132-
stdout=subprocess.PIPE,
133-
stderr=subprocess.PIPE,
134-
text=True,
135-
env=env
136-
)
137-
logging.info(f"Process started in background with PID:{self.process.pid}")
138-
139-
ifself.process.stdoutandself.process.stderr:
140-
stdout_thread=threading.Thread(target=stream_output,args=(self.process.stdout,))
141-
stderr_thread=threading.Thread(target=stream_output,args=(self.process.stderr,))
142-
143-
stdout_thread.start()
144-
stderr_thread.start()
145-
returnself.process.pid
150+
returnself.form_daemon_process(cmdline,env)
146151
else:
147152
self.test_class.output=subprocess.check_output(
148153
cmdline,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp