How to make a program exit?

Michael Kelly mkelly2002NOSPAM at earthlink.net
Wed Jan 2 11:23:32 EST 2002


On 02 Jan 2002 04:54:40 -0800, Paul Rubin <phr-n2002a at nightsong.com>
wrote:

>I can think of some brutal ways to stop the server, but it's not clear
>from the docs if there's a nice way.
>
>Any advice?  Thanks.

The recommended technique is to communicate somehow
with the running threads that they should commit suicide
and only kill them off if they haven't died in some acceptable
interval.  You should of course use a thread-safe method
of communication so that you don't get a memory access
exceptions.  Then your main thread waits until either they
have all complied with the request or the main thread
decides it must resort to murder.

So I guess this implies that you don't do operations that
block indefinitely.  There should be a time-out or some
signalling mechanism so that periodically your worker
threads can check the flag to see if it should shut
down.



Mike

--

"I don't want to belong to any club that would have me as a member."
    -- Groucho Marx



More information about the Python-list mailing list