Kill pool if interrupted/error.

This commit is contained in:
Joachim Tingvold 2015-06-06 06:45:22 +02:00
parent a169bafdd8
commit 37b63f2a4a

View File

@ -364,8 +364,13 @@ class Photo(object):
# get number of cores on the system, and use all minus one # get number of cores on the system, and use all minus one
num_of_cores = os.sysconf('SC_NPROCESSORS_ONLN') - 1 num_of_cores = os.sysconf('SC_NPROCESSORS_ONLN') - 1
pool = Pool(processes=num_of_cores) pool = Pool(processes=num_of_cores)
try:
for size in Photo.thumb_sizes: for size in Photo.thumb_sizes:
pool.apply_async(make_photo_thumbs, args = (self, original_path, thumb_path, size)) pool.apply_async(make_photo_thumbs, args = (self, original_path, thumb_path, size))
except:
pool.terminate()
pool.close() pool.close()
pool.join() pool.join()