From 3fdca19d85077d31573f17aeef7de1775daf8a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Navr=C3=A1til?= Date: Thu, 1 Aug 2024 15:01:48 +0200 Subject: [PATCH] Read JSONL line by line --- slow-post.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/slow-post.py b/slow-post.py index 52843b1..9b34399 100644 --- a/slow-post.py +++ b/slow-post.py @@ -9,7 +9,14 @@ if len(sys.argv) < 2: relay = sys.argv[1] -data = json.loads(sys.stdin.read()) +data = [] +for line in sys.stdin: + try: + item = json.loads(line) + data.append(item) + except json.JSONDecodeError as e: + print(f"Error decoding JSON: {e}", file=sys.stderr) + continue # Execute the binary for each element in the JSON array for item in data: