src/eric7/Debugger/DebuggerInterfacePython.py

branch
server
changeset 10680
306373ccf8fd
parent 10636
24d9e6ff8111
parent 10653
d169909ad8d2
child 10704
27d21e5163b8
equal deleted inserted replaced
10651:280a53840aa3 10680:306373ccf8fd
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, pyqtSlot 19 from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QTimer, pyqtSlot
19 20
20 from eric7 import Preferences, Utilities 21 from eric7 import Preferences, Utilities
1593 while sock and sock.bytesAvailable(): 1594 while sock and sock.bytesAvailable():
1594 header = sock.read(struct.calcsize(b"!II")) 1595 header = sock.read(struct.calcsize(b"!II"))
1595 length, datahash = struct.unpack(b"!II", header) 1596 length, datahash = struct.unpack(b"!II", header)
1596 1597
1597 data = bytearray() 1598 data = bytearray()
1599 now = time.monotonic()
1598 while len(data) < length: 1600 while len(data) < length:
1599 maxSize = length - len(data) 1601 maxSize = length - len(data)
1600 if sock.bytesAvailable() < maxSize: 1602 if sock.bytesAvailable() < maxSize:
1601 sock.waitForReadyRead(50) 1603 sock.waitForReadyRead(50)
1602 data += sock.read(maxSize) 1604 newData = sock.read(maxSize)
1605 if newData:
1606 data += newData
1607 else:
1608 if time.monotonic() - now > 2.0: # 2 seconds timeout
1609 break
1603 1610
1604 if zlib.adler32(data) & 0xFFFFFFFF != datahash: 1611 if zlib.adler32(data) & 0xFFFFFFFF != datahash:
1605 # corrupted data -> discard and continue 1612 # corrupted data -> discard and continue
1606 continue 1613 continue
1607 1614

eric ide

mercurial