src/eric7/Debugger/DebuggerInterfacePython.py

branch
eric7
changeset 10653
d169909ad8d2
parent 10552
c5b0c8a5fa7d
child 10659
43ead32943ca
child 10680
306373ccf8fd
child 10683
779cda568acb
equal deleted inserted replaced
10652:f788c1657f91 10653:d169909ad8d2
11 import json 11 import json
12 import logging 12 import logging
13 import os 13 import os
14 import shlex 14 import shlex
15 import struct 15 import struct
16 import time
16 import zlib 17 import zlib
17 18
18 from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QTimer 19 from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QTimer
19 20
20 from eric7 import Preferences, Utilities 21 from eric7 import Preferences, Utilities
1406 while sock and sock.bytesAvailable(): 1407 while sock and sock.bytesAvailable():
1407 header = sock.read(struct.calcsize(b"!II")) 1408 header = sock.read(struct.calcsize(b"!II"))
1408 length, datahash = struct.unpack(b"!II", header) 1409 length, datahash = struct.unpack(b"!II", header)
1409 1410
1410 data = bytearray() 1411 data = bytearray()
1412 now = time.monotonic()
1411 while len(data) < length: 1413 while len(data) < length:
1412 maxSize = length - len(data) 1414 maxSize = length - len(data)
1413 if sock.bytesAvailable() < maxSize: 1415 if sock.bytesAvailable() < maxSize:
1414 sock.waitForReadyRead(50) 1416 sock.waitForReadyRead(50)
1415 data += sock.read(maxSize) 1417 newData = sock.read(maxSize)
1418 if newData:
1419 data += newData
1420 else:
1421 if time.monotonic() - now > 2.0: # 2 seconds timeout
1422 break
1416 1423
1417 if zlib.adler32(data) & 0xFFFFFFFF != datahash: 1424 if zlib.adler32(data) & 0xFFFFFFFF != datahash:
1418 # corrupted data -> discard and continue 1425 # corrupted data -> discard and continue
1419 continue 1426 continue
1420 1427

eric ide

mercurial