How do I shutdown an HTTPServer from inside a request handler in Python?
问题 How do I shutdown this server when I receive the StopIteration exception? sys.exit() does not work. #!/usr/bin/env python from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer PORT_NUMBER = 2000 from itertools import islice filename = 'data/all.txt' file = open(filename, 'r') lines_gen = islice(file, None) class MyHandler(BaseHTTPRequestHandler): def do_GET(self): global lines_gen self.send_response(200) self.send_header('Content-type','text/plain') self.end_headers() try: for i in