I have the following code:
from subprocess import Popen, PIPE
if os.path.isfile('../'):
cmd = os.path.join(os.getcwd(), '../')
proc = Popen(["python3", "-m", cmd], stdout=PIPE, stderr=PIPE)
progRunning = True
while progRunning:
try:
output, error = proc.communicate()
except KeyboardInterrupt:
print("Program Forcequit")
progRunning = False
proc.kill()
print('Process finished')
Where ../
is the directory to a file. This program is supposed to run ../
and stop itself when it receives a KeyboardInterrupt
. However, when I try to run this code,
print
statements do not work. Here is the code in the ../
to test:
test.py
from time import *
while True:
sleep(1)
print("Hello World")
I am expecting an output of Hello World!
every 1 second. I instead get no output. How do I fix this?