Sockets, threads, and killing servers

Kenneth Jonsson kennethjonsson at
Thu Jan 10 16:51:14 EST 2002

You could use a second socket that is listening for shutdown messages and
do a select on both sockets to avoid the delay you get with the
select-with-a-timeout method.

The second socket could be used for all sorts of server control messages
(pause, resume, restart, e.t.c)

/ K

"Joshua Muskovitz" <joshm at> wrote in message
news:3c3cc04f_4 at
> > 1) Subclass the ThreadingTCPServer class so that instead of calling
> >    socket.accept() and blocking until a connection comes in, it will
> >    call with a timeout; at the end of the timeout, it
> >    will check a "Quit now?" flag and if the flag is set, will close the
> >    connection and exit. If the quit flag is not set, go back into the
> > for another N seconds.
> This is very similar to the solution we developed at my last job.  It
> well, but it means that there is a non-deterministic delay between setting
> the "self destruct" flag, and the server actually stopping.  So long as
> doesn't bother you, it should work well.
> For us, it was a concern in that the service was supposed to be highly
> reliable, so it needed to be restarted quickly in case it crashed.  But
> there was a small race condition between the shutdown of the old process
> the startup of the new, especially because of contention for owning the
> server's TCP port.
> -- j
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

More information about the Python-list mailing list