Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How can I kill CGIHTTPServer ?

Reply
Thread Tools

How can I kill CGIHTTPServer ?

 
 
eching
Guest
Posts: n/a
 
      02-11-2008
I'm running CGIHTTPServer with the serve_forever method and I cannot
get the darn thing to stop unless I kill the command prompt its
running in. I searched for similar posts here and found this:

http://groups.google.com/group/comp....7d0aa2be964767

But there doesn't seem to be a definitive answer. I tried one of the
last proposed solutions:

class Server(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
pause = 0.25
allow_reuse_address = True

def __init__(self, server_address, RequestHandlerClass):
SocketServer.TCPServer.__init__(self, server_address,
RequestHandlerClass)
self.socket.settimeout(self.pause)
self.serving = 1
...

def serve_forever(self):
while self.serving:
self.handle_request()

And that worked, but the last post in the thread suggested '...this
would cause timeouts in the middle of handling request whenever a
client is slow'

Can anyone comment on this solution or have other possible solutions?
Eventually I probably will want this to run as a windows service to
serve up some internal apps, so it would be great if I could the
server to shutdown gracefully.

Thanks in advance,
Eric
 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      02-11-2008
eching wrote:
> I'm running CGIHTTPServer with the serve_forever method and I cannot
> get the darn thing to stop unless I kill the command prompt its
> running in. I searched for similar posts here and found this:
>
> http://groups.google.com/group/comp....7d0aa2be964767
>
> But there doesn't seem to be a definitive answer. I tried one of the
> last proposed solutions:
>
> class Server(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
> pause = 0.25
> allow_reuse_address = True
>
> def __init__(self, server_address, RequestHandlerClass):
> SocketServer.TCPServer.__init__(self, server_address,
> RequestHandlerClass)
> self.socket.settimeout(self.pause)
> self.serving = 1
> ...
>
> def serve_forever(self):
> while self.serving:
> self.handle_request()
>
> And that worked, but the last post in the thread suggested '...this
> would cause timeouts in the middle of handling request whenever a
> client is slow'
>
> Can anyone comment on this solution or have other possible solutions?
> Eventually I probably will want this to run as a windows service to
> serve up some internal apps, so it would be great if I could the
> server to shutdown gracefully.
>
> Thanks in advance,
> Eric


It really might be a good idea to patch serve_forever in the library to
allow handlers to raise a specific StopServing exception. At the moment
IIRC the position is that there's a generic trap of pretty much all
exceptions, which isn't too helpful. I suppose a counter-argument might
be that "forever" has a defined meaning, and the method is correctly
named, but that's mere semantics.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      02-11-2008
En Mon, 11 Feb 2008 04:18:04 -0200, eching <(E-Mail Removed)>
escribi�:

> I'm running CGIHTTPServer with the serve_forever method and I cannot
> get the darn thing to stop unless I kill the command prompt its
> running in. I searched for similar posts here and found this:


See this thread from last year; it's about XMLRPC but the idea is the same.
http://groups.google.com/group/comp....8f06ef80e07a39

--
Gabriel Genellina

 
Reply With Quote
 
eching
Guest
Posts: n/a
 
      02-12-2008
On Feb 11, 10:24 am, "Gabriel Genellina" <(E-Mail Removed)>
wrote:
> En Mon, 11 Feb 2008 04:18:04 -0200, eching <(E-Mail Removed)>
> escribi�:
>
> > I'm running CGIHTTPServer with the serve_forever method and I cannot
> > get the darn thing to stop unless I kill the command prompt its
> > running in. I searched for similar posts here and found this:

>
> See this thread from last year; it's about XMLRPC but the idea is the same..http://groups.google.com/group/comp....thread/thread/...
>
> --
> Gabriel Genellina


That looks about like what I need. Thanks for the link!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
KILL BABY KILL widescreen drsd2kill DVD Video 3 11-29-2004 09:36 PM
Bava's KILL BABY KILL widescreen drsd2kill DVD Video 0 11-27-2004 12:04 AM
Re: Securing PyDoc and CGIHTTPserver Peter Hansen Python 7 07-15-2003 01:03 PM
Re: Securing PyDoc and CGIHTTPserver Shane Hathaway Python 1 07-11-2003 05:05 PM



Advertisments