Make demo_logging pause while writing stdout

This commit is contained in:
Tim Van Baak 2023-05-30 14:38:36 -07:00
parent e432cac969
commit 096a594813
1 changed files with 10 additions and 3 deletions

View File

@ -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:])