diff --git a/pybind11/setup_helpers.py b/pybind11/setup_helpers.py index 84a4584c5..1050f6125 100644 --- a/pybind11/setup_helpers.py +++ b/pybind11/setup_helpers.py @@ -410,7 +410,9 @@ class ParallelCompile(object): compiler._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) try: - import multiprocessing + # Importing .synchronize checks for platforms that have some multiprocessing + # capabilities but lack semaphores, such as AWS Lambda and Android Termux. + import multiprocessing.synchronize from multiprocessing.pool import ThreadPool except ImportError: threads = 1