process wrapper?

Steve @ Waypath steve at waypath.com
Mon Mar 29 22:59:18 CEST 2004


"Donn Cave" <donn at u.washington.edu> wrote in message
news:donn-440440.12045829032004 at nntp4.u.washington.edu...
> In article <QZ2dnbPGnqPo6_Xd38DK-g at speakeasy.net>,
>  "Steve @ Waypath" <steve at waypath.com> wrote:
>
> > ##########
> > File: test1.py
> > ------------
> > import os, time
> > if __name__=='__main__':
> >  os.spawnv(os.P_NOWAIT,'python',['test2.py'])
>
>
> But don't give it python's path.  Instead, at least consider
> invoking the Python program file directly - put its path there
> as the 2nd parameter, not python's.  Then your argument list
> (the 3rd parameter) will be correct as written.  If you invoke
> python itself, then you'll need to make test2.py the second
> argument, directing python to interpret that file.  If you
> decide to do as I suggest, test2.py will have to be executable
> (chmod 755) and start with a line like "#!/usr/bin/python", as
> appropriate for your system.  From there on, your test1.py
> program no longer needs to know how test2.py is actually
> implemented.
>

This makes sense to me. I tried this originally, and tried again just now.
For reasons not clear to me, I get the error:
      bad interpreter: No such file or directory
when I include the path to the python interperter. I've tried a number of
approaches:
  #!python
  #!/usr/bin/python
  #!/usr/bin/env python

(I've got the x bit set on the test files, so it's not a permissions
problem. ) This, I'm guessing, isn't a python problem, and would seem to be
my roadblock. I've done some preliminary searches for an answer, but nothing
has panned out so far; if anyone has any ideas...

>
> > ###########
> > While test 1 is running, a ps (in another shell):
> > # ps x | grep python
> > 11726 pts/1  S   0:00  python test1.py
> > 11727 pts/1  Z   0:00 [python <defunct>]
> > 11729 pts/2  S   0:00 grep python
> >
> > ###########
> > I see this defunct thing with every spawnv test I try. The defunct
process
> > goes away when the calling process (test1.py, in this case) finishes.
Where
> > am I going wrong here?
>
> It's a zombie!  UNIX leaves a dead process in the table as
> long as its parent might come back and ask for the status.
> It goes either when the parent gets its status with a wait
> function (like waitpid()), or when the parent exits.

I've read other posts (many yours, I think :) indicating something like
this, but I confess I don't understand the relationship between waitpid()
and spawnv(), how I would use the former with the latter. However, as I
recognize that isn't the solution to my problem, I won't ask you to explain
it--unless you really want to. :)

>
>    Donn Cave, donn at drizzle.com





More information about the Python-list mailing list