From ca64c31ca9071414ea53797df39dce8e44742db8 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 29 Oct 2023 03:43:09 -0500 Subject: [PATCH] read all of the response in the python getcurrent script --- scripts/getcurrent.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/getcurrent.py b/scripts/getcurrent.py index 77c50e7..4a1ac78 100644 --- a/scripts/getcurrent.py +++ b/scripts/getcurrent.py @@ -15,12 +15,24 @@ else: socktype = socket.AF_UNIX sockaddr = "/var/run/yggdrasil/yggdrasil.sock" +def readall(sock): + data = [] + sock.settimeout(1) + while True: + try: + frag = sock.recv(4096) + data.append(frag) + except: + break + return "".join(data) + + def doRequest(req): try: ygg = socket.socket(socktype, socket.SOCK_STREAM) ygg.connect(sockaddr) ygg.send(req) - data = json.loads(ygg.recv(1048576)) + data = json.loads(readall(ygg)) return data except: return None