forked from M-Labs/artiq
revert busy polling
This commit is contained in:
parent
1e9a131386
commit
4c743cf8af
|
@ -217,13 +217,13 @@ class CommKernel:
|
||||||
def _read(self, length):
|
def _read(self, length):
|
||||||
# cache the reads to avoid frequent call to recv
|
# cache the reads to avoid frequent call to recv
|
||||||
while len(self.read_buffer) < length:
|
while len(self.read_buffer) < length:
|
||||||
while True:
|
# the number is just the maximum amount
|
||||||
try:
|
# when there is not much data, it would return earlier
|
||||||
flag = socket.MSG_DONTWAIT
|
diff = length - len(self.read_buffer)
|
||||||
new_buffer = self.socket.recv(8192, flag)
|
flag = 0
|
||||||
break
|
if diff > 8192:
|
||||||
except BlockingIOError:
|
flag |= socket.MSG_WAITALL
|
||||||
pass
|
new_buffer = self.socket.recv(8192, flag)
|
||||||
if not new_buffer:
|
if not new_buffer:
|
||||||
raise ConnectionResetError("Core device connection closed unexpectedly")
|
raise ConnectionResetError("Core device connection closed unexpectedly")
|
||||||
self.read_buffer += new_buffer
|
self.read_buffer += new_buffer
|
||||||
|
|
Loading…
Reference in New Issue