bpo-38848: compileall fails when the platform lacks a working sem_open()
Co-Authored-By: Xavier de Gaye <xdegaye@gmail.com>
This commit is contained in:
parent
9baf242fc7
commit
80c7ca7124
|
@ -79,6 +79,10 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False,
|
|||
# Only import when needed, as low resource platforms may
|
||||
# fail to import it
|
||||
from concurrent.futures import ProcessPoolExecutor
|
||||
# bpo-38848: The multiprocessing module used by
|
||||
# ProcessPoolExecutor is not functional when the
|
||||
# multiprocessing.synchronize module cannot be imported.
|
||||
import multiprocessing.synchronize
|
||||
except ImportError:
|
||||
workers = 1
|
||||
if maxlevels is None:
|
||||
|
|
|
@ -169,6 +169,10 @@ class CompileallTestsBase:
|
|||
|
||||
@mock.patch('concurrent.futures.ProcessPoolExecutor')
|
||||
def test_compile_pool_called(self, pool_mock):
|
||||
# bpo-38848: The multiprocessing module used by
|
||||
# ProcessPoolExecutor is not functional when the
|
||||
# multiprocessing.synchronize module cannot be imported.
|
||||
support.import_module('multiprocessing.synchronize')
|
||||
compileall.compile_dir(self.directory, quiet=True, workers=5)
|
||||
self.assertTrue(pool_mock.called)
|
||||
|
||||
|
@ -179,6 +183,10 @@ class CompileallTestsBase:
|
|||
|
||||
@mock.patch('concurrent.futures.ProcessPoolExecutor')
|
||||
def test_compile_workers_cpu_count(self, pool_mock):
|
||||
# bpo-38848: The multiprocessing module used by
|
||||
# ProcessPoolExecutor is not functional when the
|
||||
# multiprocessing.synchronize module cannot be imported.
|
||||
support.import_module('multiprocessing.synchronize')
|
||||
compileall.compile_dir(self.directory, quiet=True, workers=0)
|
||||
self.assertEqual(pool_mock.call_args[1]['max_workers'], None)
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix :mod:`compileall` when the platform lacks a functional ``sem_open()``.
|
Loading…
Reference in New Issue