Stopping a *HTTPServer

SteveR steve at grandfathersaxe.demon.co.uk
Sat May 26 02:53:05 EDT 2001


David LeBlanc <whisper at oz.nospamnet> wrote:
>In article <67abb823.0105250734.24705e9d at posting.google.com>, 
>mt_horeb at yahoo.com says...
>> Here's the situation - I'm building a quick-and-dirty application that
>> serves CGI and HTML via the CGIHTTPServer module.  So far, so good. 
>> The only issue that I am having is that I cannot figure out how to
>> stop the server once I've started it with serve_forever().
>> 
>> I've taken a look at some newsgroup posts and Web sites (incl.
>> http://www.python.org), but I cannot seem to locate an answer!  I
>> would certainly appreciate anything that is more 'elegant' than simply
>> using Ctrl-C!
>> 
>> Here is the (very basic) code to create and start the server:
[snip]
>> Thanks!
>> 
>> Sloth
>> 
>What's your objection to Ctrl-C? If it's the abrupt nature of the 
>termination, just trap the Ctrl-C and do cleanup before exiting.

I would like to be able to stop one of these servers, *under program
control*.  My application has a "hidden" admin page which allows the
server to be stopped.  At the moment, I'm using os._exit, but this is
just as inelegant as Ctrl-C/Ctrl-Break.

Is there a tidier way than os._exit?

-- 
SteveR



More information about the Python-list mailing list