os.spawnve and threads

Anthony Roach aroach at electriceyeball.com
Mon Dec 3 00:39:20 EST 2001


I'm working on the scons project (www.scons.org) and we are having trouble
using spawnve with a parallel build. From a single Python instance
containing N threads, we want to execute spawnve N times so we get N
parallel processes. On UNIX we use os.fork() followed by os.execve(), but on
Windows we must use os.spawnve()  because there is no fork. The problem with
os.spawnve() is that it seems to block the interpreter so no other threads
can run, thus destroying our parallelism. I took a look at posixmodule.c
(where spawnve is implemented for Windows) and the problem appears to be
that Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS is not being used around
the call to _spawnve().

Is this a known bug? Any chance of getting it fixed for Python 2.2? Should I
submit a patch?

On a related note, the doc string for spawnve says "Execute a path with
arguments and environment, replacing current process", which is incorrect.
It should say "Execute a path with arguments and environment in a new
process".

All of the above problems also apply to os.spawnv().





More information about the Python-list mailing list