From 096a594813050d3692b7b264a91b73bec326e2b8 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 30 May 2023 14:38:36 -0700 Subject: [PATCH] Make demo_logging pause while writing stdout --- tests/demo_logging/update.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/demo_logging/update.py b/tests/demo_logging/update.py index 28c61a0..f4e820f 100755 --- a/tests/demo_logging/update.py +++ b/tests/demo_logging/update.py @@ -5,10 +5,17 @@ import os import sys import time -for i in range(3): +greeting = os.environ.get("HELLO", "MISSING") +item = json.dumps({ + "id": "helloworld", + "title": "Hello = " + greeting +}) +sys.stdout.write(item[:10]) +sys.stdout.flush() + +for i in range(5): sys.stderr.write(f"{i+1}...\n") sys.stderr.flush() time.sleep(1) -item = json.dumps({"id": "helloworld", "title": "Hello = " + os.environ.get("HELLO", "MISSING")}) -print(item) +sys.stdout.write(item[10:])