13

鉴于没有 Windows fork() 调用,Python 2.6 中的多处理包是如何在 Windows 下实现的?在 Win32 线程之上或某种假分叉之上,或者只是在现有多线程之上的兼容性?

4

1 回答 1

30

It's done using a subprocess call to sys.executable (i.e. start a new Python process) followed by serializing all of the globals, and sending those over the pipe. A poor man's cloning of the current process. This is the cause of the extra restrictions found when using multiprocessing on Windows plaform.

You may also be interested in viewing Jesse Noller's talk from PyCon about multiprocessing where he discusses its use.

于 2009-04-19T10:41:44.520 回答