How to wait for a child that respawns itself with os.execv() on win32?

By : jkp

I have some code that uses pip to bootstrap a Python envionment for out build process: this is a lovely way of ensuring we get proper isolation of the build requirements from the rest of the host system, and helping us get more consistent build results overall.

Anyway, the code I have that drives appears to have some problems on windows. The problem is that I'm spawning the pip process from my bootstrapping scripts using subprocess.Popen() and then waiting for the process to complete but this is happening too early due to the fact that pip uses execv to relaunch itself under the new virtualenv it creates. When this happens my parent is seeing that the child has exited with an exitcode of 0 and it carries on on it's merry way.

So the question is simple: how can I cope with an os.execv() call from a child process on win32 in manner where i can ascertain the return code of the newly executed child process?

By : jkp


I can't think of any smooth way to handle this. This may sound dirty, but perhaps you could work with dropping flag files onto the filesystem while your script is running, and wait for those files to be cleaned up?

By : Dave

This video can help you solving your question :)
By: admin