> > I don't get the "it's not applicable in this case" part. The way you 
> start them on web2py is the same one you can use with the scheduler.... 
>
> Does not seem applicable because does not address the problem of 
> dependent child processes. 
>
 
Let's not get lost: you have something to start and it dies when the 
webserver dies. For long-running processes (instead of the webserver's) , 
the recommended way is the scheduler (conceptually you don't have to stop 
it, and when you'll deploy your app on apache your external process won't 
get reapead automatically by apache itself). 
Saying that you not address the issue of dependent child processes is true, 
but the scheduler suggestion was made to you because conceptually you don't 
kill it (and as an outband process, it's not managed by the webserver, so 
it can live forever)
 

> > If you just need to launch them and never communicate with 
> > those again, did you try with 
> > import subprocess 
> > subprocess.Popen([whatever], stdout=subprocess.PIPE, 
> stderr=subprocess.PIPE, 
> > stdin=subprocess.PIPE) 
>
> Unfortunately this is still a child process so faces original problem. 
>

import os
import subprocess

print 'my pid is ', os.getpid()

other = subprocess.Popen(['/bin/ping','127.0.0.1'], 
stdout=subprocess.PIPE,stderr
=subprocess.PIPE, stdin=subprocess.PIPE)

print 'just spawned ', other.pid

What is your platform ?
on linux that works fine. 
For Windows things can get a little complicated.
output of the previous on linux
niphlod@li-mostro7:~/Scrivania$ python script.py 
my pid is  4921
just spawned  4922
niphlod@li-mostro7:~/Scrivania$ ps 4921
  PID TTY      STAT   TIME COMMAND
niphlod@li-mostro7:~/Scrivania$ ps 4922
  PID TTY      STAT   TIME COMMAND
 4922 pts/1    S      0:00 /bin/ping 127.0.0.1

4921 ended, 4922 continues to live (if I don't kill it)
 

> Using a separate service like at command is a good idea, however I 
> need to know the process ID. 
>
 
What prevents you to code your external process to save its pid when 
started so you can fetch it from another process ?

-- 



Reply via email to