def run(self):
    self._server.running = True
while self._server.running:
    self._server.handle_request()

def start(self):
    self._thread.start()

def shut_down(self):
    self._thread.close()
m = MainServer()
m.start()
How to stop a simplehttpserver in python from httprequest handler?