diff -r a111134b5dc7 -r c38750e1bafd RefactoringRope/JsonServer.py --- a/RefactoringRope/JsonServer.py Wed Sep 27 19:50:44 2017 +0200 +++ b/RefactoringRope/JsonServer.py Fri Sep 29 10:23:35 2017 +0200 @@ -37,6 +37,7 @@ """ super(JsonServer, self).__init__(parent) + self.__name = name self.__multiplex = multiplex if self.__multiplex: self.__clientProcesses = {} @@ -58,9 +59,9 @@ self.newConnection.connect(self.handleNewConnection) port = self.serverPort() - ## Note: Need the port if started external in debugger: - print('JSON server ({1}) listening on: {0:d}'.format(port, name)) - # __IGNORE_WARNING__ + ## Note: Need the port if client is started external in debugger. + print('JSON server ({1}) listening on: {0:d}' # __IGNORE_WARNING__ + .format(port, self.__name)) @pyqtSlot() def handleNewConnection(self): @@ -137,7 +138,8 @@ data = connection.readLine() jsonLine = bytes(data).decode("utf-8", 'backslashreplace') -## print("JSON Server: ", jsonLine) ##debug +## print("JSON Server ({0}): {1}".format( +## self.__name, jsonLine)) ##debug try: clientDict = json.loads(jsonLine.strip()) @@ -235,15 +237,21 @@ self.sendJson("Exit", {}, flush=True, idString=idString) if idString: - connection = self.__connections[idString] + try: + connection = self.__connections[idString] + except KeyError: + connection = None else: connection = self.__connection if connection is not None: connection.waitForDisconnected() if idString: - self .__clientProcesses[idString].close() - del self.__clientProcesses[idString] + try: + self .__clientProcesses[idString].close() + del self.__clientProcesses[idString] + except KeyError: + pass else: if self.__clientProcess is not None: self.__clientProcess.close()