From 37b63f2a4ab74b2d1ef77405b93f198a78f9eea8 Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Sat, 6 Jun 2015 06:45:22 +0200 Subject: [PATCH] Kill pool if interrupted/error. --- scanner/PhotoAlbum.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py index 52ae647..6370c49 100644 --- a/scanner/PhotoAlbum.py +++ b/scanner/PhotoAlbum.py @@ -364,8 +364,13 @@ class Photo(object): # get number of cores on the system, and use all minus one num_of_cores = os.sysconf('SC_NPROCESSORS_ONLN') - 1 pool = Pool(processes=num_of_cores) - for size in Photo.thumb_sizes: - pool.apply_async(make_photo_thumbs, args = (self, original_path, thumb_path, size)) + + try: + for size in Photo.thumb_sizes: + pool.apply_async(make_photo_thumbs, args = (self, original_path, thumb_path, size)) + except: + pool.terminate() + pool.close() pool.join()