Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python daemon process

Reply
Thread Tools

Python daemon process

 
 
Thomas Dybdahl Ahle
Guest
Posts: n/a
 
      08-26-2006
Hi, I'm writing a program, using popen4(gnuchess),
The problem is, that gnuchess keeps running after program exit.

I know about the atexit module, but in java, you could make a process a
daemon process, and it would only run as long as the real processes ran. I
think this is a better way to stop gnuchess, as you are 100% sure, that
it'll stop.

Can you do this with popen?

--
Thomas
 
Reply With Quote
 
 
 
 
faulkner
Guest
Posts: n/a
 
      08-26-2006
process = subprocess.Popen(gnuchess)
....
os.kill(process.pid, signal.SIGKILL)

Thomas Dybdahl Ahle wrote:
> Hi, I'm writing a program, using popen4(gnuchess),
> The problem is, that gnuchess keeps running after program exit.
>
> I know about the atexit module, but in java, you could make a process a
> daemon process, and it would only run as long as the real processes ran. I
> think this is a better way to stop gnuchess, as you are 100% sure, that
> it'll stop.
>
> Can you do this with popen?
>
> --
> Thomas


 
Reply With Quote
 
 
 
 
Paolo Pantaleo
Guest
Posts: n/a
 
      08-27-2006
2006/8/26, Thomas Dybdahl Ahle <(E-Mail Removed)>:
> Hi, I'm writing a program, using popen4(gnuchess),
> The problem is, that gnuchess keeps running after program exit.
>
> I know about the atexit module, but in java, you could make a process a
> daemon process, and it would only run as long as the real processes ran. I
> think this is a better way to stop gnuchess, as you are 100% sure, that
> it'll stop.
>
> Can you do this with popen?
>
> --
> Thomas
> --
> http://mail.python.org/mailman/listinfo/python-list
>

You could send the quit (or close or wahtever) command to gnuchess
when you want it to terminate. Supposing that gnuchess needs to do
some stuff on exit, this is a better solution.

PAolo

--
if you have a minute to spend please visit my photogrphy site:
http://mypic.co.nr
 
Reply With Quote
 
Thomas Dybdahl Ahle
Guest
Posts: n/a
 
      08-29-2006
I might not have made myself very clear, since you both got me wrong.
What I need, is not a method to terminate a process, but a way to
terminate a process when the main process dies.

From the atexit module info:
Note: the functions registered via this module are not called when the
program is killed by a signal, when a Python fatal internal error is
detected, or when os._exit() is called.

I belive that there is noway you can be sure to get a piece of code run,
if the program crashes or something like that,
therefor I ask for a way to run gnuchess as a kind of subprocess, that can
only run when the parrentprocess is still running.

I know this is called a daemon thread in java.

> 2006/8/26, Thomas Dybdahl Ahle <(E-Mail Removed)>:
>> Hi, I'm writing a program, using popen4(gnuchess),
>> The problem is, that gnuchess keeps running after program exit.
>>
>> I know about the atexit module, but in java, you could make a process a
>> daemon process, and it would only run as long as the real processes ran. I
>> think this is a better way to stop gnuchess, as you are 100% sure, that
>> it'll stop.
>>
>> Can you do this with popen?
>>
>> --
>> Thomas
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>

> You could send the quit (or close or wahtever) command to gnuchess
> when you want it to terminate. Supposing that gnuchess needs to do
> some stuff on exit, this is a better solution.
>
> PAolo


--
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks of
Europe's Dark Ages; they are the only ones with the training and insight
to read and interpret the "scripture" of this age.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Floris Bruynooghe Python 1 03-24-2009 02:58 PM
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Jean-Paul Calderone Python 0 03-20-2009 01:02 PM
Making a non-root daemon process Ben Finney Python 3 03-24-2007 08:16 AM
Creating a daemon process in Python Sakagami Hiroki Python 9 02-23-2007 02:30 PM
Daemon Win32::Daemon; ph1975@gmail.com Perl Misc 0 09-07-2006 10:58 AM



Advertisments