Use Popen.communicate() instead of read() in stacktrace_handler_test.py.

This avoids potential deadlock, see the warnings in
https://docs.python.org/2/library/subprocess.html#popen-objects. I
found that enabling the C API caused us to deadlock without this
change.

PiperOrigin-RevId: 183730170
This commit is contained in:
Skye Wanderman-Milne 2018-01-29 14:40:07 -08:00 committed by TensorFlower Gardener
parent c7351055a8
commit a807755db1

View File

@ -57,7 +57,8 @@ class StacktraceHandlerTest(test.TestCase):
# Capture its output. capture both stdout and stderr and append them.
# We are not worried about timing or order of messages in this test.
child_output = child_process.stdout.read() + child_process.stderr.read()
child_stdout, child_stderr = child_process.communicate()
child_output = child_stdout + child_stderr
# Make sure the child process is dead before we proceed.
child_process.wait()