Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SocketServer
- class BackgroundReqHandler(SocketServer.BaseRequestHandler, SocketPipe):
- def route(self, path, *args):
- handler = HDLRS.get(path, None)
- if handler: handler(self, *args)
- else: error("server handler", path, "not found")
- def handle(self):
- self.route(*self.recv_data())
- #Reuse a local socket in TIME_WAIT state, without waiting for its timeout to expire
- class BackgroundServer(SocketServer.ThreadingTCPServer):
- allow_reuse_address = True
- server = BackgroundServer((SHARED_SERVER_ADDR, SHARED_SERVER_PORT), \
- BackgroundReqHandler)
- debug("start listening...")
- server.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment