RefactoringRope/JsonClient.py

branch
server_client_variant
changeset 164
121d426d4ed7
parent 163
6a9e7b37a18b
child 166
6fc202183b3b
diff -r 6a9e7b37a18b -r 121d426d4ed7 RefactoringRope/JsonClient.py
--- a/RefactoringRope/JsonClient.py	Tue Sep 12 18:55:25 2017 +0200
+++ b/RefactoringRope/JsonClient.py	Thu Sep 14 19:39:11 2017 +0200
@@ -130,3 +130,29 @@
         time.sleep(0.5)
         self.__connection.shutdown(socket.SHUT_RDWR)
         self.__connection.close()
+    
+    def poll(self):
+        """
+        Public method to check and receive one message (if available)
+        """
+        try:
+            rrdy, wrdy, xrdy = select.select([self.__connection], [], [], 0)
+            if self.__connection in rrdy:
+                self.__receiveJson()
+        
+        except (select.error, KeyboardInterrupt, socket.error):
+            # just ignore these
+            return
+        
+        except Exception:
+            exctype, excval, exctb = sys.exc_info()
+            tbinfofile = io.StringIO()
+            traceback.print_tb(exctb, None, tbinfofile)
+            tbinfofile.seek(0)
+            tbinfo = tbinfofile.read()
+            del exctb
+            self.sendJson("ClientException", {
+                "ExceptionType": str(exctype),
+                "ExceptionValue": str(excval),
+                "Traceback": tbinfo,
+            })

eric ide

mercurial