diff --git a/foobar/kiss.py b/foobar/kiss.py index 610381a..65b9ff9 100644 --- a/foobar/kiss.py +++ b/foobar/kiss.py @@ -7,14 +7,15 @@ def main(): que = queue.Queue() event = threading.Event() + config = {'output': '/tmp/test_out', 'input': '/tmp/test_in'} #input(que) - input_thread = threading.Thread(target=handle_input, args=(que,event)) + input_thread = threading.Thread(target=handle_input, args=(que,event,config)) input_thread.daemon = True input_thread.start() #output(que) - output_thread = threading.Thread(target=handle_output, args=(que,event)) + output_thread = threading.Thread(target=handle_output, args=(que,event,config)) output_thread.daemon = True output_thread.start() @@ -24,20 +25,22 @@ def main(): print("\nDone!") event.set() -def handle_input(que, event): +def handle_input(que, event, config): loop = 0 + file = config['input'] while not event.is_set(): - message = f"{time.time()} | Hi! {loop}" + message = f"{time.time()} | Hi! | {file} | {loop}" que.put(message) loop = loop + 1 time.sleep(1) -def handle_output(que, event): +def handle_output(que, event, config): file = '/tmp/test_out' + future_file = config['output'] with open(file, 'a') as out_file: while not event.is_set(): message = que.get() - out_file.write(f"{message}\r\n") + out_file.write(f"{future_file} | {message}\r\n") out_file.flush() time.sleep(1)