import os,time,pathlib p=pathlib.Path("heartbeat.jsonl") i=0 while True: i+=1 with p.open("a") as f:f.write(str(os.getpid())+" "+str(i)+"\n") print("heartbeat",os.getpid(),i,flush=True) time.sleep(.25)