From 358ffaa235a18a366ccd423ce565c4544d5e5a3c Mon Sep 17 00:00:00 2001 From: kalzu rekku Date: Sun, 11 Feb 2024 09:24:45 +0200 Subject: [PATCH] working again... --- foobar/kiss.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/foobar/kiss.py b/foobar/kiss.py index a4dc3d0..610381a 100644 --- a/foobar/kiss.py +++ b/foobar/kiss.py @@ -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__":