self._start_server()
def _start_server(self):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.bind(("localhost", 8888)) // check if port 8888 is available
original_cwd = os.getcwd()
After Change
class Server(socketserver.TCPServer):
// http://stackoverflow.com/questions/10613977/a-simple-python-server-using-simplehttpserver-and-socketserver-how-do-i-close-t
allow_reuse_address = True
server = Server(("localhost", port), Handler)
import threading
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()