News for hackers. Stuff that matters.
Re:Thread pools: How do I use them? by metachris on Sunday March 27, 2016 @05:09PM (#11371566)
I recently ran into the issue that the multiprocessing.pool.ThreadPool class is not cancellable in Python 2. It seems that only in Python 3 can you exit a ThreadPool with eg. a KeyboardInterrupt before all tasks are finished.

Since then I've been using this code, which works great across all platforms and Python versions: https://github.com/metachris/pdfx/blob/master/pdfx/threadpoo...

Re:Thread pools: How do I use them? by megamouse on Sunday March 27, 2016 @07:26PM (#11371964)
I've experienced this bug in Python 2 using "pool.map" and "pool.apply", but KeyboardInterrupt does work if you're waiting for a finite amount of time. So as a workaround you can use "result = pool.map_async(...); result.get(sys.maxint)". A little hacky but functional.