diff --git a/optimage.py b/optimage.py index 7e904a9..2a77c80 100644 --- a/optimage.py +++ b/optimage.py @@ -16,6 +16,7 @@ import collections import contextlib import logging +import multiprocessing.pool import os import os.path import shutil @@ -173,9 +174,15 @@ def _compress_with(input_filename, output_filename, compressors): input. """ with _temporary_filenames(len(compressors)) as temp_filenames: - results = [] - for compressor, temp_filename in zip(compressors, temp_filenames): - results.append(_process(compressor, input_filename, temp_filename)) + process_args = [ + (compressor, input_filename, temp_filename) + for compressor, temp_filename in zip(compressors, temp_filenames) + ] + process_unpack = lambda args: _process(*args) + results = multiprocessing.pool.ThreadPool().map(process_unpack, + process_args, + chunksize=1) + best_result = min(results) os.rename(best_result.filename, output_filename) diff --git a/setup.py b/setup.py index bb11f12..4b04c14 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ scripts=['scripts/optimage'], setup_requires=['pytest-runner'], install_requires=['Pillow'], - tests_require=['pytest', 'pytest-cov', 'pytest-catchlog'], + tests_require=['pytest>=3.3', 'pytest-cov'], classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Console', diff --git a/test_optimage_e2e.py b/test_optimage_e2e.py index e3bd388..5442e5e 100644 --- a/test_optimage_e2e.py +++ b/test_optimage_e2e.py @@ -3,11 +3,6 @@ import subprocess import pytest -try: - import pytest_catchlog - catchlog_available = True -except ImportError: - catchlog_available = False import optimage @@ -147,8 +142,6 @@ def mock_check_output(args, stderr=None): assert 'Output:\ncustom error' in err -@pytest.mark.skipif(not catchlog_available, - reason='pytest_catchlog not available') @pytest.mark.parametrize('filename, compressor', [ # Do not specify compressor as it depends on the version of the commands # installed. In Mac I get that pngcrush is better than zopflipng, but not in