Modified the JSON stream reader to ensure all data is read before the connection is closed. unittest

Mon, 23 May 2022 16:49:08 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 23 May 2022 16:49:08 +0200
branch
unittest
changeset 9090
224c634a1808
parent 9089
b48a6d0f6309
child 9091
4231a14a89d7

Modified the JSON stream reader to ensure all data is read before the connection is closed.

eric7/EricNetwork/EricJsonStreamReader.py file | annotate | diff | comparison | revisions
--- a/eric7/EricNetwork/EricJsonStreamReader.py	Mon May 23 16:48:19 2022 +0200
+++ b/eric7/EricNetwork/EricJsonStreamReader.py	Mon May 23 16:49:08 2022 +0200
@@ -105,6 +105,7 @@
         Private slot handling a disconnect of the writer.
         """
         if self.__connection is not None:
+            self.__receiveJson()    # read all buffered data first
             self.__connection.close()
         
         self.__connection = None
@@ -114,10 +115,8 @@
         """
         Private slot handling received data from the writer.
         """
-        connection = self.__connection
-        
-        while connection and connection.canReadLine():
-            dataStr = connection.readLine()
+        while self.__connection and self.__connection.canReadLine():
+            dataStr = self.__connection.readLine()
             jsonLine = bytes(dataStr).decode("utf-8", 'backslashreplace')
             
             #- print("JSON Reader ({0}): {1}".format(self.__name, jsonLine))

eric ide

mercurial