简体   繁体   English

Boost.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.我想将我的 C++ 代码与 Python 的multiprocessing一起使用,以便从不同的进程并行调用我的 C++ 代码。 The code does not save any state and no memory sharing is required between the different processes.该代码不保存任何 state 并且不同进程之间不需要 memory 共享。 I decided to use Boost/Python to allow my C++ library to be imported into Python.我决定使用 Boost/Python 将我的 C++ 库导入 Python。

However, this FAQ says that Boost/Python is not compatible with multiple interpreters.但是,这个常见问题解答说 Boost/Python 与多个解释器不兼容。 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?具体来说,这是否意味着通过multiprocessing的 Boost/Python 调用我的 C++ 代码会有问题?

Multiple processes don't require more than 1 interpreter per process.多个进程每个进程不需要超过 1 个解释器。

Also, the way you describe the situation is that you use a native module from Python.此外,您描述这种情况的方式是您使用来自 Python 的本机模块。 In that case Python is supplying the interpreter, anyways.在那种情况下,无论如何 Python 正在提供解释器。

The way I understand the 1-interpreter limitation applies to embedding python from within C++ - a rather limited subset of the Boost Python features.我理解 1-interpreter 限制的方式适用于从 C++ 中嵌入 python - Boost Python 功能的一个相当有限的子集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM