A tale of two execs

Carl Banks pavlovevidence at gmail.com
Tue Feb 24 05:04:16 EST 2009


On Feb 23, 9:13 pm, aha <aquil.abdul... at gmail.com> wrote:
> Hello All,
>   It occurred to me that I might just want to try copying the
> subprocess.py installed in a /usr/lib/python24 installation to the
> directory where I place the scripts that I need to launch my
> application...I know this was mentioned earlier.  Anyway, my
> application worked under python 2.3 and later python versions as
> well.  Here is what I did:
>
> I renamed subprocess.py to subprocess23.py and then used the following
> code:
>
> try:
>   import subprocess
> except ImportError:
>   import subprocess23 as subprocess
>
> I chose this route because I took a deeper look at the code in the
> subprocess module and I also realized that I would not be able to use
> the popen2, because I would not be able to do things like os.setpgrp
> for preexec_fn, with popen2.  In the end, if I wanted that type of
> functionality I would have to use os.dup, fork, exec, which meant
> reinventing the wheel.  I overcame the issue of dealing with msvcrt
> and _subprocess under windows by requiring python24 or greater under
> windows.


Distributing the interpreter doesn't look quite as silly as it did
this morning now, does it?


Carl Banks



More information about the Python-list mailing list