On 10/22/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
Alan means to use two or three threads *total*.
Orri, I took another look at your program and you are not using threads correctly; the way you have it set up you are just doing one conversion at a time. Your main loop is roughly like this:
for each track
make a thread pool
queue a request to convert the track
wait for all threads to finish (but there is only one)
finish converting the track
Since you wait for each thread individually, the processing ends up being sequential.
You should put all the processing for a track in convert_thread and structure your code like this:
make a thread pool with 2-3 threads
for each track
queue a request to convert the track
wait for all threads to finish
finish up - processing that has to be done after all threads complete
With this structure, you will always be running 2-3 conversions at a time; when one finishes you will start another until they are all done. You might want to print 'starting' and 'finishing' messages in convert_thread so you can see the overlap.
When you get it working, experiment with the number of threads in the pool to see what number gives the best performance.
--
Email: singingxduck AT gmail DOT com
AIM: singingxduck
Programming Python for the fun of it.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor