Jorge Louis de Castro wrote:
> Are these two equivalent:
> 
> def run_server(socket):
>      ...
> 
> 1)
> thread = Thread(target=run_server, args=(server,))
> #thread.setDaemon(True)
> thread.start()
> 
> 2)
> server.listen(1)
> thread.start_new_thread(run_server,(server,))

They both start threads but the threading module also modifies the behavior of 
sys.exit() so the program will not exit until all *non* daemon threads exit. So 
you may get the behaviour you want with 1) as written (without the setDaemon() 
call). Calling setDaemon(True) *allows* the program to exit before the daemon 
thread terminates which sounds like the opposite of what you want.

Kent

> 
> So that I can uncomment the setDaemon() method?
> 
> chrs
> j.
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to