IPython 引擎是独立进程吗?

Are IPython engines independent processes?

IPython Architecture Overview 文档我们知道...

The IPython engine is a Python instance that takes Python commands over a network connection.

鉴于它是一个 Python 实例,这是否意味着这些引擎是独立的进程?我可以通过 ipcluster start -n 4 这样的命令手动加载一组引擎。这样做是将引擎的创建视为某些父进程的子进程的创建,还是只是启动一组依赖 IPC 通信来完成其工作的独立进程的一种方式?我还可以通过 ipengine 命令调用一个引擎,它肯定是独立的,因为它直接输入到 OS 命令行,与任何东西都没有关系。

作为背景,我正在尝试深入研究 python 脚本中通过客户端操作的许多 IPython 引擎将与该脚本中启动的另一个进程交互。

这是找出涉及的进程的简单方法,在我启动控制器和引擎之前打印当前进程的列表,然后在它们启动后打印列表。有一个 wmic 命令来完成工作...

C:\>wmic process get description,executablepath

有趣的是,控制器让 5 个 python 进程运行,并且每个引擎创建一个额外的 python 进程。所以从这次调查中我也了解到引擎是它自己的进程,还有控制器...

C:\>wmic process get description,executablepath | findstr ipengine
ipengine.exe                   C:\Python34\Scripts\ipengine.exe
ipengine.exe                   C:\Python34\Scripts\ipengine.exe

C:\>wmic process get description,executablepath  | findstr ipcontroller
ipcontroller.exe               C:\Python34\Scripts\ipcontroller.exe

从外观上看,它们似乎都是独立的,但我不认为 OS 的 运行 进程列表包含有关进程如何相关的任何信息,就 parent/child关系而言。这可能是一种仅限开发人员的形式主义,没有在 OS 中跟踪的表示形式,但我不知道这些内部结构如何知道。

这是来自 MinRK 的权威 quote 直接解决了这个问题:

"Every engine is its own isolated process...Each kernel is a separate process and can be on any machine... It's like you started a terminal IPython session, and every engine is a separate IPython session. If you do a=5 in this one, a=10 in that one, this guy has 10 this guy has 5."

这是进一步的确定性验证,灵感来自 ServerFault 上的一个伟大的 SE Hot Network Question,其中提到使用实际跟踪父子进程的 ProcessExplorer...

Process Explorer is a Sysinternals tool maintained by Microsoft. It can display the command line of the process in the process's properties dialog as well as the parent that launched it, though the name of that process may no longer be available. --Corrodias

如果我在另一个命令中启动更多引擎 window,那么 ProcessExplorer 的那部分就会完全复制,就像您在屏幕截图中看到的那样。

为了完整起见,下面是命令 ipcluster start --n=5 的样子...