Can multiprocessing.Process() use a different version of the interpreter?

Robert Kern robert.kern at gmail.com
Mon Oct 4 13:34:19 EDT 2010


On 10/4/10 11:39 AM, Scott Pigman wrote:

> I believe that the solution is to have both win32 and x64 versions of
> python installed, and then execute the win32 code inside of a new
> process which uses the win32 version of Python.  I'm already using
> multiprocessing to run that code inside a new process because the two
> libraries have conflicts and need to run in separate memory space.  If
> I could just specify that I want the new process to use a different
> version of the interpreter I think I'd be all set, but I don't see a
> way of doing that.

My previous statement notwithstanding, there is a way to hack this. The 
windows-specific implementation of the class multiprocessing.forking.Popen uses 
a global variable, _python_exe, to determine the executable to use. Instead, you 
could subclass Popen to use whatever executable you like and subclass Process to 
use this Popen. See the source files process.py and forking.py in the 
multiprocessing package. It should be straightforward to attempt, but I don't 
know for sure that it will work.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list