multiprocessing module

M

makobu

I have a function that makes two subprocess.Popen() calls on a file.

I have 8 cores. I need 8 instances of that function running in
parallel at any given time till all the files are worked on.
Can the multiprocessing module do this? If so, whats the best method?

A technical overview of how the multiprocessing module actually works
would also be really helpful.

regards,
mak.
 
A

Aahz

I have a function that makes two subprocess.Popen() calls on a file.

I have 8 cores. I need 8 instances of that function running in
parallel at any given time till all the files are worked on.
Can the multiprocessing module do this? If so, whats the best method?

You don't quite explicitly say so, but it sounds like you have multiple
files. In which case, yes, it should be reasonably straightforward to
use multiprocessing; I haven't used it myself, but what you want must be
whatever is equivalent to Queue.Queue().
A technical overview of how the multiprocessing module actually works
would also be really helpful.

Not having any clue what you already know makes that rather a daunting
prospect, as indicated by the lack of replies. Maybe you could
summarize?
 
G

Glazner

I have a function that makes two subprocess.Popen() calls on a file.

I have 8 cores. I need 8 instances of that function running in
parallel at any given time till all the files are worked on.
Can the multiprocessing module do this? If so, whats the best method?

A technical overview of how the multiprocessing module actually works
would also be really helpful.

regards,
mak.

I guess you need the Map-Reduce pattern.
It appears like multiprocessing.Pool will do the trick.

def doSomething(f):
pass

pool = Pool(8)# 8 processes 1 per core

files = ['pop.txt','looper.txt','foo.bar']
results = pool.map(doSomething,files) #this does all the job

got it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top