RefactoringRope/JsonServer.py

branch
server_client_variant
changeset 168
53d76b4fc1ac
parent 166
6fc202183b3b
child 175
72a1d9030d67
--- a/RefactoringRope/JsonServer.py	Sat Sep 16 18:51:19 2017 +0200
+++ b/RefactoringRope/JsonServer.py	Sun Sep 17 17:03:16 2017 +0200
@@ -11,7 +11,7 @@
 
 import json
 
-from PyQt5.QtCore import pyqtSlot, QProcess, QThread
+from PyQt5.QtCore import pyqtSlot, QProcess
 from PyQt5.QtNetwork import QTcpServer, QHostAddress
 
 from E5Gui import E5MessageBox
@@ -133,7 +133,7 @@
         """
         pass
     
-    def sendJson(self, command, params):
+    def sendJson(self, command, params, flush=False):
         """
         Public method to send a single refactoring command to the client.
         
@@ -141,6 +141,8 @@
         @type str
         @param params dictionary of named parameters for the command
         @type dict
+        @param flush flag indicating to flush the data to the socket
+        @type bool
         """
         commandDict = {
             "jsonrpc": "2.0",
@@ -151,6 +153,8 @@
         
         if self.__connection is not None:
             self.__connection.write(cmd.encode('utf8', 'backslashreplace'))
+            if flush:
+                self.__connection.flush()
     
     def startClient(self, interpreter, clientScript, clientArgs):
         """
@@ -183,12 +187,10 @@
         """
         Public method to stop the client process.
         """
-        self.sendJson("Exit", {})
+        self.sendJson("Exit", {}, flush=True)
         
-        QThread.msleep(200)
+        if self.__connection is not None:
+            self.__connection.waitForDisconnected()
         
         self.__clientProcess.close()
         self.__clientProcess = None
-
-#
-# eflag: noqa = M801

eric ide

mercurial