p = subprocess.Popen('gdb.exe',
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE,
shell=False,
bufsize=0)
stdoutThread = StreamThread(io.TextIOWrapper(p.stdout))
stdoutThread.start()
stdinThread = StreamThread(io.TextIOWrapper([p.stdin))
stdinThread.start()
p.communicate() # input output communicate
stdinThread.join()
stdoutThread.join()
for i in range(0, 10):
if # minute elapsed
# print stack trace to gdb
print('bt\n' , file=p.stdin)
# delay
#return result stack trace to python script
print("stdout %s", file=p.stdout)
Thread(target=stream_reader, name='stdout-o',
args=('STDOUT', proc.stdout)).start()
Thread(target=stream_writer, name='stderr-i',
args=('STDIN', proc.stdin)).start()