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
As others noted, the threading module offers Thread.setDaemon.
As the doc says: "The entire Python program exits when no active
non-daemon threads are left."
Python starts your program with one (non-daemon) thread which
is sometimes called the "main" thread. I suggest creating all
other threads as daemons. The process will then exit when the
main thread exits.
If some other thread needs to end the process, it does so by
telling the main thread to exit. For example, we might leave
the main thread waiting at a lock (or semaphore), and exit if
the lock is ever released.
> it seems that the follow doesn't work, in my Windows XP:
> thread.start()
> thread.join()
Is that part of the questions above, or another issue?
--
--Bryan
The parent thread only has to set the flag to cause the children to die.
Kevin.
"Bryan Olson" <fakea...@nowhere.org> wrote in message
news:g2fyf.888$H71...@newssvr13.news.prodigy.com...
Doesn't work, because threads can be blocked. Worse,
some threads may be blocked waiting for others to release
them. The unblocked threads check the flag and exit, so
they're never signal the blocked ones.
--
--Bryan