Ritesh Raj Sarraf wrote:

> Duncan,
> 
> I couldn't make out much from the code.
> Instead this is what I did.
> 
> threads = []
>         nloops = range(len(lRawData))
>         for i in nloops:
>             (sUrl, sFile, download_size, checksum) =
> stripper(lRawData[i])
>             t = threading.Thread(target=download_from_web, args=(sUrl,
> sFile, sSourceDir, None))
>             # = pypt_thread(download_from_web, i,
> stripper(lRawData[i]))
>             threads.append(t)
> 
>         i = 0
>         join_i = 0
>         while i < nloops:
>             counter = 0
>             while counter < 3:
>                 threads[i].start()
>                 counter += 1
>                 i += 1
>             counter = 0
>             join_i = i - 3
>             while counter < 3:
>                 threads[join_i].join()
>                 counter += 1
>                 join_i += 1
> 
> Is this correct ? Comments!!
> 
This is bad because you start one thread for each URL then let them run in 
batches of 3. So you get all the overhead of creating lots of threads and 
very little of the benefit. Much better just to create 3 threads and let 
each one handle as many of the requests as it can.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to