[Tutor] Thread deamon

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Mon Aug 22 15:41:25 CEST 2005


Well, I don't know how it works on Windows, but on UNIX, if you want to
create a deamon able to stay alive when you deconnect you "just" have to
catch the HUP signal and ... do nothing of it :) By default this signal
exit the application.

You have two ways of doing so :
 1 - use the standard signal handling to intercept the SIGHUP signal and
ignore it
 2 - launch your program using "nohup" :
$ nohup my_prg

In both cases it should stay alive after the death of the terminal.

Pierre

Jorge Louis de Castro a écrit :
> Hi,
> 
> 
> Anyone knows how to setDaemon(True) or pass it as an argument to 
> start_new_thread() with the code snippet below?
> 
> server.listen(1)
> thread.start_new_thread(run_server,(server,))
> 
> Otherwise the thread stops running when I close the telnet client (even 
> using Unix's & operator for background running)
> 
> chrs
> j.
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68


More information about the Tutor mailing list