working again...
This commit is contained in:
parent
63c10720c6
commit
358ffaa235
@ -9,12 +9,12 @@ def main():
|
|||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
|
|
||||||
#input(que)
|
#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.daemon = True
|
||||||
input_thread.start()
|
input_thread.start()
|
||||||
|
|
||||||
#output(que)
|
#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.daemon = True
|
||||||
output_thread.start()
|
output_thread.start()
|
||||||
|
|
||||||
@ -24,23 +24,22 @@ def main():
|
|||||||
print("\nDone!")
|
print("\nDone!")
|
||||||
event.set()
|
event.set()
|
||||||
|
|
||||||
def input(que, event):
|
def handle_input(que, event):
|
||||||
loop = 0
|
loop = 0
|
||||||
while not event:
|
while not event.is_set():
|
||||||
message = f"{time.time()} | Hi! {loop}"
|
message = f"{time.time()} | Hi! {loop}"
|
||||||
que.put(message)
|
que.put(message)
|
||||||
loop = loop + 1
|
loop = loop + 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
def output(que, event):
|
def handle_output(que, event):
|
||||||
file = '/tmp/test_out'
|
file = '/tmp/test_out'
|
||||||
with open(file, 'a') as out_file:
|
with open(file, 'a') as out_file:
|
||||||
while not event:
|
while not event.is_set():
|
||||||
message = que.get()
|
message = que.get()
|
||||||
out_file.write(f"{message}\r\n")
|
out_file.write(f"{message}\r\n")
|
||||||
out_file.flush()
|
out_file.flush()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
out_file.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user