Sockets, threads, and killing servers
kennethjonsson at bredband.net
Thu Jan 10 22:51:14 CET 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
The second socket could be used for all sorts of server control messages
(pause, resume, restart, e.t.c)
"Joshua Muskovitz" <joshm at taconic.net> wrote in message
news:3c3cc04f_4 at corp.newsgroups.com...
> > 1) Subclass the ThreadingTCPServer class so that instead of calling
> > socket.accept() and blocking until a connection comes in, it will
> > call select.select() 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
> > select.select() 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 =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
More information about the Python-list