RefactoringRope/JsonClient.py

changeset 307
84fba41b2f6f
parent 302
2e853e2f2430
child 326
67bcde9c65b9
--- a/RefactoringRope/JsonClient.py	Sun Feb 03 15:28:02 2019 +0100
+++ b/RefactoringRope/JsonClient.py	Fri Feb 22 19:11:22 2019 +0100
@@ -37,7 +37,6 @@
             order to identify the connection
         @type str
         """
-        self.__exitClient = False
         self.__connection = socket.create_connection((host, port))
         if idString:
             reply = idString + '\n'
@@ -123,31 +122,26 @@
         """
         try:
             selectErrors = 0
-            while True:
+            while selectErrors <= 10:  # selected arbitrarily
                 try:
                     rrdy, wrdy, xrdy = select.select(
                         [self.__connection], [], [])
+                    
+                    # Just waiting for self.__connection. Therefor no check
+                    # needed.
+                    method, params = self.__receiveJson()
+                    if method is None:
+                        selectErrors += 1
+                    elif method == "Exit":
+                        break
+                    else:
+                        self.handleCall(method, params)
+                        
+                        # reset select errors
+                        selectErrors = 0
+                
                 except (select.error, KeyboardInterrupt, socket.error):
                     selectErrors += 1
-                    if selectErrors <= 10:      # selected arbitrarily
-                        # just carry on
-                        continue
-                    else:
-                        break
-                
-                # reset select errors
-                selectErrors = 0
-                
-                if self.__connection in rrdy:
-                    method, params = self.__receiveJson()
-                    if method is not None:
-                        if method == "Exit":
-                            self.__exitClient = True
-                        else:
-                            self.handleCall(method, params)
-                
-                if self.__exitClient:
-                    break
         
         except Exception:
             exctype, excval, exctb = sys.exc_info()

eric ide

mercurial