Mafe the Python debugger interface a bit more resilient against the debug client not sending data. eric7

Tue, 02 Apr 2024 09:46:36 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 02 Apr 2024 09:46:36 +0200
branch
eric7
changeset 10653
d169909ad8d2
parent 10652
f788c1657f91
child 10655
a9bb50b60608

Mafe the Python debugger interface a bit more resilient against the debug client not sending data.

src/eric7/Debugger/DebuggerInterfacePython.py file | annotate | diff | comparison | revisions
--- a/src/eric7/Debugger/DebuggerInterfacePython.py	Tue Apr 02 09:46:04 2024 +0200
+++ b/src/eric7/Debugger/DebuggerInterfacePython.py	Tue Apr 02 09:46:36 2024 +0200
@@ -13,6 +13,7 @@
 import os
 import shlex
 import struct
+import time
 import zlib
 
 from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QTimer
@@ -1408,11 +1409,17 @@
             length, datahash = struct.unpack(b"!II", header)
 
             data = bytearray()
+            now = time.monotonic()
             while len(data) < length:
                 maxSize = length - len(data)
                 if sock.bytesAvailable() < maxSize:
                     sock.waitForReadyRead(50)
-                data += sock.read(maxSize)
+                newData = sock.read(maxSize)
+                if newData:
+                    data += newData
+                else:
+                    if time.monotonic() - now > 2.0:  # 2 seconds timeout
+                        break
 
             if zlib.adler32(data) & 0xFFFFFFFF != datahash:
                 # corrupted data -> discard and continue

eric ide

mercurial