From 5c287be4c10cd22088d6bbf2877a6d443cb4bf12 Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Tue, 5 Apr 2022 19:28:25 +0200 Subject: [PATCH] Fix pickle error with pool_init --- sigal/gallery.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sigal/gallery.py b/sigal/gallery.py index ffe11a2..6956331 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -793,11 +793,11 @@ class Gallery: self.logger.info("Using %s cores", ncpu) if ncpu > 1: - def pool_init(): - if self.settings['max_img_pixels']: - PILImage.MAX_IMAGE_PIXELS = self.settings['max_img_pixels'] - - self.pool = multiprocessing.Pool(processes=ncpu, initializer=pool_init) + self.pool = multiprocessing.Pool( + processes=ncpu, + initializer=pool_init, + initargs=(self.settings['max_img_pixels'],), + ) else: self.pool = None @@ -931,6 +931,11 @@ class Gallery: yield f +def pool_init(max_img_pixels): + if max_img_pixels: + PILImage.MAX_IMAGE_PIXELS = max_img_pixels + + def process_file(media): processor = None if media.type == 'image':