python subprocess become idle after a while

I have two script, one is for reading serial port continuously and other script is for running the serial port reading script in background. The script given below is I used for running as subprocess.
subprocess.Popen("echo " + user_password + " | sudo -S " + filePath  shell=True, stdout=subprocess.PIPE)
if i run serial port reading script manually, it will not idle, it runs contineously. But if i use the above script for running as subprocess, the serial port reading script become idle after a few minutes. How i can stop this idle issue?

Ans: 
I think, if you go for multi processing instead of subprocess, you don't get idle issue
def executeOsCommand:
    os.system(command)

command = "echo " + user_password + " | sudo -S " + filePath
p = multiprocessing.Process(target=executeOsCommand, args=(command,))
p.start()

Comments

Popular posts from this blog

Install canon LBP2900 driver in linux

show preview of pdf file saved in gridfs on browser