I have two functions, draw_ascii_spinner
and findCluster(companyid)
.
I would like to:
findCluster(companyid)
in the backround and while its processing.... draw_ascii_spinner
until findCluster(companyid)
finishesHow do I begin to try to solve for this (Python 2.7)?
Use threads:
import threading, time
def wrapper(func, args, res):
res.append(func(*args))
res = []
t = threading.Thread(target=wrapper, args=(findcluster, (companyid,), res))
t.start()
while t.is_alive():
# print next iteration of ASCII spinner
t.join(0.2)
print res[0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With