Commit 949c416d authored by Serhiy Storchaka's avatar Serhiy Storchaka

Merge heads

parents 71b49dde d86ef05a
...@@ -142,8 +142,8 @@ Public functions ...@@ -142,8 +142,8 @@ Public functions
The argument *workers* specifies how many workers are used to The argument *workers* specifies how many workers are used to
compile files in parallel. The default is to not use multiple workers. compile files in parallel. The default is to not use multiple workers.
If the platform can't use multiple workers and *workers* argument is given, If the platform can't use multiple workers and *workers* argument is given,
then a :exc:`NotImplementedError` will be raised. then sequential compilation will be used as a fallback. If *workers* is
If *workers* is lower than ``0``, a :exc:`ValueError` will be raised. lower than ``0``, a :exc:`ValueError` will be raised.
.. versionchanged:: 3.2 .. versionchanged:: 3.2
Added the *legacy* and *optimize* parameter. Added the *legacy* and *optimize* parameter.
......
...@@ -69,11 +69,9 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, ...@@ -69,11 +69,9 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels, files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
ddir=ddir) ddir=ddir)
success = 1 success = 1
if workers is not None and workers != 1: if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
if workers < 0: if workers < 0:
raise ValueError('workers must be greater or equal to 0') raise ValueError('workers must be greater or equal to 0')
if ProcessPoolExecutor is None:
raise NotImplementedError('multiprocessing support not available')
workers = workers or None workers = workers or None
with ProcessPoolExecutor(max_workers=workers) as executor: with ProcessPoolExecutor(max_workers=workers) as executor:
......
...@@ -136,10 +136,10 @@ class CompileallTests(unittest.TestCase): ...@@ -136,10 +136,10 @@ class CompileallTests(unittest.TestCase):
self.assertTrue(compile_file_mock.called) self.assertTrue(compile_file_mock.called)
@mock.patch('compileall.ProcessPoolExecutor', new=None) @mock.patch('compileall.ProcessPoolExecutor', new=None)
def test_compile_missing_multiprocessing(self): @mock.patch('compileall.compile_file')
with self.assertRaisesRegex(NotImplementedError, def test_compile_missing_multiprocessing(self, compile_file_mock):
"multiprocessing support not available"): compileall.compile_dir(self.directory, quiet=True, workers=5)
compileall.compile_dir(self.directory, quiet=True, workers=5) self.assertTrue(compile_file_mock.called)
class EncodingTest(unittest.TestCase): class EncodingTest(unittest.TestCase):
"""Issue 6716: compileall should escape source code when printing errors """Issue 6716: compileall should escape source code when printing errors
......
...@@ -15,6 +15,9 @@ Core and Builtins ...@@ -15,6 +15,9 @@ Core and Builtins
Library Library
------- -------
- Issue #23917: Fall back to sequential compilation when ProcessPoolExecutor
doesn't exist. Patch by Claudiu Popa.
- Issue #23008: Fixed resolving attributes with boolean value is False in pydoc. - Issue #23008: Fixed resolving attributes with boolean value is False in pydoc.
- Fix asyncio issue 235: LifoQueue and PriorityQueue's put didn't - Fix asyncio issue 235: LifoQueue and PriorityQueue's put didn't
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment