test-client.py: Close pipes and print logs on timeout failures

If we failed on process wait, we didn't close the pipes and no clear output
of what happened was exposed.

So use a finally stanza to close the pipes and print stdout and stderr
on failure.
This commit is contained in:
Marco Trevisan (Treviño)
2019-09-30 19:51:30 +02:00
committed by Thomas Haller
parent 6a58c55ca4
commit 36bd0565b7

View File

@@ -425,15 +425,29 @@ class AsyncProcess():
self.start()
Util.popen_wait(self._p, 2000)
error = False
try:
Util.popen_wait(self._p, 2000)
except Exception as e:
error = True
raise e
finally:
(returncode, stdout, stderr) = (self._p.returncode,
self._p.stdout.read(),
self._p.stderr.read())
(returncode, stdout, stderr) = (self._p.returncode, self._p.stdout.read(), self._p.stderr.read())
self._p.stdout.close()
self._p.stderr.close()
self._p = None
self._p.stdout.close()
self._p.stderr.close()
self._p = None
if error:
print(stdout)
print(stderr)
self._complete_cb(self, returncode, stdout, stderr)
try:
self._complete_cb(self, returncode, stdout, stderr)
except Exception as e:
raise e
###############################################################################