I am calling a function (that can't be modified) to analyze data and it could take anywhere from minutes to hours to complete. I am trying to print the status/progress periodically to let the user know that the analysis is still progressing.
Since:
- I don't know how long the analysis takes a priori and
- I am restricted to using Python's standard library
then using the progressbar package wouldn't work. I am able to achieve this using multiprocessing:
import multiprocessing.pool import ThreadPool
import time
def analysis():
#Perform analysis that takes a long time and cannot be modified
pool = ThreadPool(processes=2)
t = pool.apply_async(func = analysis)
start_time = time.time()
while not t.ready():
print "Analyzing..."
time.sleep(2)
It would be great if I could avoid using multiprocess and it could simply update in-place like the linux "watch" command.