Skip to content
Merged
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
36 changes: 25 additions & 11 deletions cli/tests/integration/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,31 @@ def terminate_on_exit(proc: subprocess.Popen) -> subprocess.Popen:
try:
yield proc
finally:
stderr = None
try:
stdout, stderr = proc.communicate(timeout=1)
except subprocess.TimeoutExpired as e:
process = psutil.Process(proc.pid)
for child in process.children(recursive=True):
child.kill()
process.kill()
stdout, stderr = proc.communicate()
if stderr is not None:
print(stderr)
process = psutil.Process(proc.pid)
for child in process.children(recursive=True):
child.kill()
process.kill()


# TODO: Figure out a way to read process stderr reliably.
# proc.communicate() may hang even with timeout.
#
# @contextmanager
# def terminate_on_exit(proc: subprocess.Popen) -> subprocess.Popen:
# try:
# yield proc
# finally:
# stderr = None
# try:
# stdout, stderr = proc.communicate(timeout=1)
# except subprocess.TimeoutExpired as e:
# process = psutil.Process(proc.pid)
# for child in process.children(recursive=True):
# child.kill()
# process.kill()
# stdout, stderr = proc.communicate()
# if stderr is not None:
# print(stderr)


def wait_hub(host: str = HUB_HOST, port: str = HUB_PORT, attempts=10):
Expand Down