Yields parsed JSON messages from stdin, one per line.
()
| 55 | |
| 56 | |
| 57 | def recv(): |
| 58 | """Yields parsed JSON messages from stdin, one per line.""" |
| 59 | for raw in sys.stdin: |
| 60 | raw = raw.strip() |
| 61 | if raw: |
| 62 | try: |
| 63 | yield json.loads(raw) |
| 64 | except json.JSONDecodeError as exc: |
| 65 | send({"type": "log", "level": "error", |
| 66 | "message": f"Runner: invalid JSON on stdin: {exc}"}) |
| 67 | |
| 68 | |
| 69 | # ------------------------------------------------------------------ # |