[Tutor] Thread deamon
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Mon Aug 22 20:11:05 CEST 2005
On Mon, 22 Aug 2005, Jorge Louis de Castro wrote:
> 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)
Hi Jorge,
It appears that you're using the low-level thread library:
http://www.python.org/doc/lib/module-thread.html
But it looks like you're looking at threading.setDaemon(), which comes
as part of the high-level 'threading' library.
http://www.python.org/doc/lib/thread-objects.html
Those are two separate modules: 'threading' builds on top of 'thread', so
I'd recommend using 'threading'. You can replace:
thread.start_new_thread(run_server,(server,))
with:
child = threading.Thread(target=run_server, args=(server,))
child.setDaemon(True)
child.start()
Hope this helps!
More information about the Tutor
mailing list