I want to invoke infinite loop script from parent code.
from subprocess import Popen
import subprocess
import os
import sys
proc=subprocess.Popen([sys.executable, os.getcwd()+'/A.py'],shell=False, stdout=subprocess.PIPE)
print(proc.communicate())
print('Hi')
and my script is:
import time
def main():
while True:
print('HI2')
time.sleep(3)
if __name__ == '__main__':
main()`
but it does not work and does Popen block the script. I mean that why print('Hi') syntax does not work.