Use subprocesses in simple way...

Serge Orlov Serge.Orlov at gmail.com
Thu May 11 10:35:30 EDT 2006


DurumDara wrote:
> 10 May 2006 04:57:17 -0700, Serge Orlov <Serge.Orlov at gmail.com>:
> > I thought md5 algorithm is pretty light, so you'll be I/O-bound, then
> > why bother with multi-processor algorithm?
>
> This is an assessor utility.
> The program's architecture must be flexible, because I don't know,
> where it need to run (only I have a possibility to fix this: I write
> to user's guide).
>
> But I want to speedup my alg. with native code, and multiprocess code.
> I not tested yed, but I think that 4 subprocess quickly as one large
> process.

I believe you need to look at Queue module. Using Queue will help you
avoid threading hell that you're afraid of (and rightly so!). Create
two queues: one for jobs, another one for results, the main thread
submits jobs and picks up results for results queue. As soon as number
of results == number of jobs, it's time to quit. Submit N special jobs
that indicate it's time to exit, where N is the number of worker
threads. Then "join" the main thread with worker threads and exit the
application.




More information about the Python-list mailing list