working again...

This commit is contained in:
kalzu rekku 2024-02-11 09:24:45 +02:00
parent 63c10720c6
commit 358ffaa235

View File

@ -9,12 +9,12 @@ def main():
event = threading.Event()
#input(que)
input_thread = threading.Thread(target=input, args=(que,event))
input_thread = threading.Thread(target=handle_input, args=(que,event))
input_thread.daemon = True
input_thread.start()
#output(que)
output_thread = threading.Thread(target=output, args=(que,event))
output_thread = threading.Thread(target=handle_output, args=(que,event))
output_thread.daemon = True
output_thread.start()
@ -24,23 +24,22 @@ def main():
print("\nDone!")
event.set()
def input(que, event):
def handle_input(que, event):
loop = 0
while not event:
while not event.is_set():
message = f"{time.time()} | Hi! {loop}"
que.put(message)
loop = loop + 1
time.sleep(1)
def output(que, event):
def handle_output(que, event):
file = '/tmp/test_out'
with open(file, 'a') as out_file:
while not event:
while not event.is_set():
message = que.get()
out_file.write(f"{message}\r\n")
out_file.flush()
time.sleep(1)
out_file.close()
if __name__ == "__main__":