Windows如何实现Python多处理? [英] How's Python Multiprocessing Implemented on Windows?

查看:93
本文介绍了Windows如何实现Python多处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于没有Windows fork()调用,如何在Windows下实现Python 2.6中的多处理程序包?是在Win32线程之上还是某种虚假的fork之上,还是仅在现有多线程之上具有兼容性?

解决方案

这是通过对sys.executable的子过程调用(即启动新的Python进程)完成的,然后序列化所有全局变量,然后通过管道发送这些全局变量.一个穷人正在克隆当前的进程.这是在Windows平台上使用多重处理时发现额外限制的原因. /p>

您可能也有兴趣查看 PyCon的Jesse Noller关于多处理的演讲,它的用途.

Given the absence of a Windows fork() call, how's the multiprocessing package in Python 2.6 implemented under Windows? On top of Win32 threads or some sort of fake fork or just compatibility on top of the existing multithreading?

解决方案

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.

这篇关于Windows如何实现Python多处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆