RefactoringRope/JsonClient.py

branch
server_client_variant
changeset 166
6fc202183b3b
parent 164
121d426d4ed7
child 168
53d76b4fc1ac
--- a/RefactoringRope/JsonClient.py	Fri Sep 15 19:50:07 2017 +0200
+++ b/RefactoringRope/JsonClient.py	Sat Sep 16 16:40:50 2017 +0200
@@ -18,7 +18,6 @@
 import socket
 import select
 import traceback
-import time
 import json
 
 
@@ -35,6 +34,7 @@
         @param port port of the background service
         @type int
         """
+        self.__exitClient = False
         self.__connection = socket.create_connection((host, port))
     
     def sendJson(self, command, params):
@@ -81,7 +81,11 @@
             
             method = commandDict["method"]
             params = commandDict["params"]
-            self.handleCall(method, params)
+            
+            if method == "Exit":
+                self.__exitClient = True
+            else:
+                self.handleCall(method, params)
     
     def handleCall(self, method, params):
         """
@@ -112,6 +116,9 @@
                 
                 if self.__connection in rrdy:
                     self.__receiveJson()
+                
+                if self.__exitClient:
+                    break
         
         except Exception:
             exctype, excval, exctb = sys.exc_info()
@@ -127,7 +134,6 @@
             })
 
         # Give time to process latest response on server side
-        time.sleep(0.5)
         self.__connection.shutdown(socket.SHUT_RDWR)
         self.__connection.close()
     

eric ide

mercurial