two questions about thread

Diez B. Roggisch deets at nospam.web.de
Sat Jan 14 12:12:53 EST 2006


iclinux wrote:
> hi there,
> 
> I'm new to python, and have two questions:
> 
> a.  how to exit the whole process in a thread?

sys.exit()

Works only if Thread.setDaemon(True) is invoked on all threads.

> b. when thread doing a infinite loops, how to terminate the process?:
>     it seems that the follow doesn't work, in my Windows XP:
>             thread.start()
>             thread.join()

It works. You just don't understand _how_ it works. There is no (easy, 
without major pain performance- and stability-wise and corner-case-free) 
way to terminate a thread. If you want that, use a subprocess & e.g. 
pyro as RPC mechanism.

Diez



More information about the Python-list mailing list