From 1c84005c3dc35d9ffffb209d89d3751470451c0e Mon Sep 17 00:00:00 2001 From: like15 Date: Thu, 16 Jul 2020 10:42:09 +0800 Subject: [PATCH] use subprocess.communicate instead of subprocess.wait in tools/python/utils/device.py --- tools/python/utils/device.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/python/utils/device.py b/tools/python/utils/device.py index 8aa755f2..9037d0c8 100644 --- a/tools/python/utils/device.py +++ b/tools/python/utils/device.py @@ -36,9 +36,11 @@ def execute(cmd, verbose=True): universal_newlines=True) if not verbose: - if p.wait() != 0: - raise Exception("\"%s\" with errorcode: %s" % (cmd, p.returncode)) - return p.stdout.read() + # use p.communicate instead of p.wait to avoid such situation: pipe is filled and the child process is blocked. + out, err = p.communicate() + if p.returncode != 0: + raise Exception("errorcode: {}".format(p.returncode) ) + return out buf = [] -- GitLab