fix: non-blocking response drain using setblocking(False)
Validate and Test / validate-patches (push) Failing after 12s
Validate and Test / validate-patches (push) Failing after 12s
This commit is contained in:
@@ -74,8 +74,6 @@ def main():
|
||||
|
||||
_poll.register(sock, POLLIN)
|
||||
|
||||
router_resp = b""
|
||||
|
||||
active_notes = set()
|
||||
last_sent_params = None
|
||||
pending_bytes = None
|
||||
@@ -145,13 +143,17 @@ def main():
|
||||
if ok:
|
||||
pending_bytes = None
|
||||
frames_sent += 1
|
||||
# Drain exactly one response to keep router buffer clear
|
||||
# Drain pending responses so router buffer stays clear
|
||||
router.setblocking(False)
|
||||
try:
|
||||
router.settimeout(0.001)
|
||||
router.recv(4096)
|
||||
except (BlockingIOError, socket.timeout, OSError):
|
||||
while True:
|
||||
chunk = router.recv(4096)
|
||||
if not chunk:
|
||||
break
|
||||
except (BlockingIOError, OSError):
|
||||
pass
|
||||
finally:
|
||||
router.setblocking(True)
|
||||
router.settimeout(0.01)
|
||||
else:
|
||||
frames_dropped += 1
|
||||
|
||||
Reference in New Issue
Block a user