Sockets, threads, and killing servers
Joshua Muskovitz
joshm at taconic.net
Wed Jan 9 17:20:50 EST 2002
> 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 worked
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 this
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 and
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
mailing list