Browse Source

Remove multiprocessing.

Because it does not work correctly and makes it harder to debug the image
operations. Will see later how to put it back.
pull/17/merge
Simon Conseil 13 years ago
parent
commit
c6ff528792
  1. 4
      docs/index.rst
  2. 6
      sigal/__init__.py
  3. 19
      sigal/gallery.py

4
docs/index.rst

@ -8,7 +8,6 @@ and it allows to build a static gallery of images with the following features:
* process directories recursively,
* generate HTML pages using jinja2 templates,
* relative links for a portable output,
* parallel processing,
* MIT licensed.
The idea behind Sigal is to ease the use of the javascript librairies like
@ -118,9 +117,6 @@ Optional arguments:
``-t THEME, --theme THEME``
Specify a theme directory, or a theme name for the themes included with Sigal
``-n NCPU, --ncpu NCPU``
Number of cpu for parallel execution (default: 1)
Configuration
-------------

6
sigal/__init__.py

@ -86,9 +86,8 @@ def init():
"the current working directory)")
@arg('-t', '--theme', help="Specify a theme directory, or a theme name for "
"the themes included with Sigal")
@arg('-n', '--ncpu', help="Number of cpu for parallel execution (default: 1)")
def build(input_dir, output_dir, debug=False, verbose=False, force=False,
config=None, theme=None, ncpu=1):
config=None, theme=None):
"""Run sigal to process a directory. """
level = (debug and logging.DEBUG) or (verbose and logging.INFO) \
@ -112,8 +111,7 @@ def build(input_dir, output_dir, debug=False, verbose=False, force=False,
sys.exit(1)
settings = read_settings(settings_file)
gal = Gallery(settings, input_dir, output_dir, force=force, theme=theme,
ncpu=ncpu)
gal = Gallery(settings, input_dir, output_dir, force=force, theme=theme)
gal.build()

19
sigal/gallery.py

@ -30,7 +30,6 @@ import shutil
import sys
from clint.textui import progress, colored
from multiprocessing import Pool
from os.path import join
from PIL import Image as PILImage
@ -144,10 +143,9 @@ class Gallery(object):
"Prepare images"
def __init__(self, settings, input_dir, output_dir, force=False,
theme=None, ncpu=1):
theme=None):
self.settings = settings
self.force = force
self.ncpu = ncpu
self.input_dir = os.path.abspath(input_dir)
self.output_dir = os.path.abspath(output_dir)
self.logger = logging.getLogger(__name__)
@ -205,8 +203,6 @@ class Gallery(object):
self.logger.info(":: Processing '%s' [%i images]",
colored.green(dirname), len(imglist))
pool = Pool(processes=self.ncpu)
try:
# loop on images
for f in img_iterator:
@ -217,23 +213,12 @@ class Gallery(object):
self.logger.info("%s exists - skipping", filename)
else:
self.logger.info(filename)
pool.apply_async(worker_image,
(f, outpath, self.settings)).get(9999)
process_image(f, outpath, self.settings)
pool.close()
pool.join()
except KeyboardInterrupt:
pool.terminate()
sys.exit('Interrupted')
def worker_image(*args):
try:
return process_image(*args)
except KeyboardInterrupt:
return 'KeyboardException'
def process_image(filepath, outpath, settings):
"""Process one image: resize, create thumbnail."""

Loading…
Cancel
Save