Page 1 of 1

Multiple python scripts running at once

Posted: Mon Dec 24, 2012 8:57 pm
by noPULSar
Hello,
I have 8 pythons scripts and i want them to run at once (like in multitasking).
Its the first time I program anything.

Thank you.

Re: Multiple python scripts running at once

Posted: Mon Dec 24, 2012 9:28 pm
by ghans
Well , that should work.
Linux is a multitasking OS.

ghans

Re: Multiple python scripts running at once

Posted: Mon Dec 24, 2012 9:33 pm
by noPULSar
I know i didn't use a "?" in my original post but how do i do that?

Re: Multiple python scripts running at once

Posted: Mon Dec 24, 2012 9:43 pm
by ghans
Hmm.

Code: Select all

./scriptname.py &
Is a simple way , the "&" should put in the background.

ghans

Re: Multiple python scripts running at once

Posted: Mon Dec 24, 2012 9:52 pm
by noPULSar
I need them to all start at the same time and maybe in loop.

More info:
I have 8LED connected to my GPIO ports and for each led i have a a script with a software pwm.
I can run them one at the time with ./1.py & for all 8 scripts and iv tried execfile(but this one starts them one after another).

Re: Multiple python scripts running at once

Posted: Mon Dec 24, 2012 10:58 pm
by noPULSar
Ok i got this working but its pretty messy.
I think i have to improve my pwm scripts.

Code: Select all

import subprocess
from time import sleep

y=(0.1)
subprocess.Popen(["python", '1.py'])
sleep(y)
subprocess.Popen(["python", '2.py'])
sleep (y)
subprocess.Popen(["python", '3.py'])
sleep (y)
subprocess.Popen(["python", '4.py'])
sleep (y)
subprocess.Popen(["python", '5.py'])
sleep(y)
subprocess.Popen(["python", '6.py'])
sleep (y)
subprocess.Popen(["python", '7.py'])
sleep (y)
subprocess.Popen(["python", '8.py'])
Thank for the help!