views:

712

answers:

1

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?

+11  A: 

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.

Adam
Adam is correct (I'm Jesse) - it's unfortunate, but all fork "implementations" on win32 are horrible hacks. Therefore we stuck with subprocess and serialization
jnoller
Thanks so much for a clear answer!
Jeff: you should mark this answer as accepted if you're happy with it.
Adam