[Tutor] : Threads?

Orri Ganel singingxduck at gmail.com
Sat Oct 22 18:29:14 CEST 2005


I knew what he meant, but since most albums have around 12 tracks, 4 tracks
per thread gives you 3 threads. In any case, thanks for the catch on the
loop. I'll let you know if it makes a difference.

On 10/22/05, Kent Johnson <kent37 at tds.net> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051022/526dbcdf/attachment-0001.html


More information about the Tutor mailing list