Re: How to kill a SocketServer?

2005-05-02 Thread [EMAIL PROTECTED]
[Skip Montanaro] def serve_forever(self): while self.serving: r,w,e = select.select([self.socket], [], [], self.pause) if r: self.handle_request() and set self.pause to something short-ish. The select call times out and the

Re: How to kill a SocketServer?

2005-05-02 Thread Guido van Rossum
[Skip Montanaro] I stumbled on a somewhat cleaner way to do this using socket timeouts: class Server(SocketServer.ThreadingMixIn, SocketServer.TCPServer): pause = 0.25 allow_reuse_address = True def __init__(self, server_address, RequestHandlerClass):

How to kill a SocketServer?

2005-05-01 Thread Paul Rubin
Let's say you have a SocketServer with the threading mix-in and you run serve_forever on it. How can you shut it down, or rather, how can it even shut itself down? Even if you use a handle_request loop instead of serve_forever, it still seems difficult: class myserver(ThreadingMixIn,

Re: How to kill a SocketServer?

2005-05-01 Thread Andrew Dalke
Paul Rubin wrote: Let's say you have a SocketServer with the threading mix-in and you run serve_forever on it. How can you shut it down, or rather, how can it even shut itself down? I looked at CherryPy's server because I know it uses Python's BaseHTTPServer which is derived from

Re: How to kill a SocketServer?

2005-05-01 Thread Skip Montanaro
Paul Let's say you have a SocketServer with the threading mix-in and Paul you run serve_forever on it. How can you shut it down, or rather, Paul how can it even shut itself down? Even if you use a Paul handle_request loop instead of serve_forever, it still seems Paul

Re: How to kill a SocketServer?

2005-05-01 Thread Paul Rubin
Skip Montanaro [EMAIL PROTECTED] writes: I use precisely that scheme with (I think *) no problem. The only maybe significant difference I see is that I subclass ThreadingMixin so that it creates daemon threads: ... According to the docs, you don't need the subclass, you can just set the

Re: How to kill a SocketServer?

2005-05-01 Thread Skip Montanaro
I use precisely that scheme with (I think *) no problem. The only maybe significant difference I see is that I subclass ThreadingMixin so that it creates daemon threads: ... Paul According to the docs, you don't need the subclass, you can just Paul set the daemon_threads

Re: How to kill a SocketServer?

2005-05-01 Thread Paul Rubin
Andrew Dalke [EMAIL PROTECTED] writes: which means it went a different route. Looks like a request comes in and is put to a work queue. Clients get from it. There's a special work queue item to tell the threads to stop. Well, ok, so the worker threads stop. How do you get the listener