Search code examples
c++boostmultiprocessingboost-python

Is Boost.Python compatible with multiprocessing?


I want to use my C++ code with Python's multiprocessing so that my C++ code is called from different processes in parallel. The code does not save any state and no memory sharing is required between the different processes. I decided to use Boost/Python to allow my C++ library to be imported into Python.

However, this FAQ says that Boost/Python is not compatible with multiple interpreters. I am trying to understand what this means exactly. Specifically, does this means that calling my C++ code through Boost/Python with multiprocessing would be problematic?


Solution

  • Multiple processes don't require more than 1 interpreter per process.

    Also, the way you describe the situation is that you use a native module from Python. In that case Python is supplying the interpreter, anyways.

    The way I understand the 1-interpreter limitation applies to embedding python from within C++ - a rather limited subset of the Boost Python features.