1

In my program I Iwant to access multiple linux shells using different process.

Currently I am using subprocess I don't have a linux machine to test this on currently so can you tell me if this works.

Does subprocess work on one terminal? If so is there an alternative?

This is something like what I am developing:

import multiprocessing
import subprocess

def doSomething(filepath):
    subprocess.call("somecommands")
    subprocess.call("somecommands")

if __name__ == "__main__":

while True:
    processList=[]
    for i in range(numberOfThreads):
        process=multiprocessing.Process(target=doSomething,args=[files])
        process.start()
        processList.append(process)
    for process in processList:
        process.join()
1
  • what do you mean by on one terminal? Commented Apr 4, 2015 at 23:28

1 Answer 1

2

You Should use the,

Popen

feature of the subprocess module, that way, I don't think you will need threading anymore since it doesn't look like you're going somewhere serious with sharing data.

Now your code should look like,

import subprocess as s_p
s_p.Popen('Command to be given','*args')
print 'Process started in a separate shell'

I believe this will do your job!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.