Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

parallel subprocess.getoutput

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


jaroslav.dobrek at gmail

May 11, 2012, 5:04 AM

Post #1 of 2 (133 views)
Permalink
parallel subprocess.getoutput

Hello,

I wrote the following code for using egrep on many large files:

MY_DIR = '/my/path/to/dir'
FILES = os.listdir(MY_DIR)

def grep(regex):
i = 0
l = len(FILES)
output = []
while i < l:
command = "egrep " + '"' + regex + '" ' + MY_DIR + '/' +
FILES[i]
result = subprocess.getoutput(command)
if result:
output.append(result)
i += 1
return output

Yet, I don't think that the files are searched in parallel. Am I
right? How can I search them in parallel?

Jaroslav
--
http://mail.python.org/mailman/listinfo/python-list


jaroslav.dobrek at gmail

May 11, 2012, 5:11 AM

Post #2 of 2 (119 views)
Permalink
Re: parallel subprocess.getoutput [In reply to]

Sorry, for code-historical reasons this was unnecessarily complicated.
Should be:


MY_DIR = '/my/path/to/dir'
FILES = os.listdir(MY_DIR)


def grep(regex):
output = []
for f in FILES:
command = "egrep " + '"' + regex + '" ' + MY_DIR + '/' + f
result = subprocess.getoutput(command)
if result:
output.append(result)
return output
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.