On Mon, Jun 20, 2011 at 1:39 AM, Laurent Claessens <moky.m...@gmail.com> wrote: > My problem is that when FileToCopyTask raises an error, the program does not > stop. > In fact when the error is Disk Full, I want to stop the whole program > because I know that the next task will fail too.
If you're starting a thread for every file you're copying, you're starting a huge number of threads that probably will just end up fighting over the disk. To get a reasonably efficient early-abort, I'd recommend having a fixed pool of worker threads (say, ten of them), and have each thread (a) check if the early-abort flag is set, and then (b) start copying the next file in queue. Once the queue's empty or the early-abort flag is set, all ten threads will terminate when they finish their current transfers. (The ten threads figure is arbitrary. Optimum value for performance will come by adjusting this.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list