src/eric7/RemoteServerInterface/EricServerInterface.py

branch
server
changeset 10762
d141283f7334
parent 10723
88bec462b855
child 10764
5915ca2466b2
diff -r 63618ecdbe57 -r d141283f7334 src/eric7/RemoteServerInterface/EricServerInterface.py
--- a/src/eric7/RemoteServerInterface/EricServerInterface.py	Sun Jun 09 16:57:49 2024 +0200
+++ b/src/eric7/RemoteServerInterface/EricServerInterface.py	Sun Jun 09 17:23:54 2024 +0200
@@ -9,7 +9,9 @@
 
 import collections
 import json
+import logging
 import struct
+import time
 import uuid
 import zlib
 
@@ -262,7 +264,14 @@
         """
         Private slot handling received data from the eric remote server.
         """
+        headerSize = struct.calcsize(b"!II")
+
         while self.__connection and self.__connection.bytesAvailable():
+            now = time.monotonic()
+            while self.__connection.bytesAvailable() < headerSize:
+                self.__connection.waitForReadyRead(50)
+                if time.monotonic() - now > 2.0:  # 2 seconds timeout
+                    return
             header = self.__connection.read(struct.calcsize(b"!II"))
             length, datahash = struct.unpack(b"!II", header)
 
@@ -284,6 +293,9 @@
 
             jsonString = data.decode("utf-8", "backslashreplace")
 
+            logging.getLogger(__name__).debug(
+                f"<Remote Server Interface Rx> {jsonString}"
+            )
             # - print("Remote Server Interface Receive: {0}".format(jsonString))
             # - this is for debugging only
 
@@ -367,6 +379,9 @@
         }
         jsonString = json.dumps(serviceDict) + "\n"
 
+        logging.getLogger(__name__).debug(
+            f"<Remote Server Interface Tx> {jsonString}"
+        )
         # - print("Remote Server Interface Send: {0}".format(jsonString))
         # - this is for debugging only
 

eric ide

mercurial