diff --git a/tools/python/utils/device.py b/tools/python/utils/device.py index 8aa755f2002a8803c259a01d362f5f12ee5eadcd..9037d0c882f26d5962df68f44e2cf97194237ea3 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 = []