Here is some relevant code:
messages = Queue()
sleeptime = 0.15
def waiting(message_queue, text, timeout):
sys.stdout.write(text + " ")
sys.stdout.flush()
i = 0
while True:
sys.stdout.write("\b" + whizzer[i % len(whizzer)])
sys.stdout.flush()
time.sleep(sleeptime)
i = i + 1
if i * sleeptime >= timeout:
print()
print("Timeout. Task took longer than " + str(timeout) + " seconds.")
break
if message_queue.empty():
continue
else:
flag = message_queue.get(block = False)
if flag is _finished:
sys.stdout.write("\r")
sys.stdout.flush()
print ()
print("Task is complete. Took " + str(i * sleeptime) + " seconds")
# for i in range(len(text) + 3):
# sys.stdout.write(" ")
# sys.stdout.flush()
break
if flag is _interrupted:
break
wait = Thread(target = waiting, args = (messages, "Waiting for browser to open and web page to download", 20))
wait.start()
driver.get('https://www.opinionstage.com/registrations/login')
messages.put(_finished)
Here is a typical piece of output to stdout (and/or stderr) that I would like to tidy up:
Processing exam number 0 (topic: air-law)
Waiting for image to upload —[10516:14800:0304/160133.041:ERROR:device_event_log_impl.cc(211)] [16:01:33.041] Bluetooth: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed.
\
Task is complete. Took 59.4 seconds
Processing question no. 0
The monitor thread outputs "Waiting for image to upload —", then the main thread (I suppose) outputs "[10516:14800:0304/160133.041:ERROR:device_event_log_impl.cc(211)] [16:01:33.041] Bluetooth: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed.". Then the monitor thread outputs lots of -\|/ sequences until the task is complete. I would like to delay the error message until the monitor thread has stopped outputing. How do I do this?
Thanks - Rowan