Simon Forman wrote: > > One other question I had, > > If my user passes the --zip option, download_from_web() internally (when the > > download is successful) zips the downloaded data to a zip file. Since in > > case > > of threading there'll be multiple threads, and say if one of the thread > > completes 2 seconds before others and is doing the zipping work: > > What will the other thread, at that moment do, if it completes while the > > previous thread is doing the zipping work ? > > The other threads will just take the next request from the Queue and > process it. They won't "care" what the one thread is doing, > downloading, zipping, whatever. > >
The thread will be marked as complete only when the function that it executed exits. Right ? download_from_web() internally calls a funtion to zip the file. So it doesn't return before zipping. Till then this thread is not complete and therefore is busy working (i.e. zipping). during the same time if another thread (which is also calling download_from_web) completes the download, the download function will again call the zip code. At that particular situtation, will it wait for the previous thread to complete the zipping and release the file so that it can zip more data to it or will it just panic and quit ? I think this shouldn't be much concern. The d_f_w() calls zip(). And since zip opens the file.zip file in append mode, no matter how many threads access it, it should be okay. Ritesh -- http://mail.python.org/mailman/listinfo/python-list