Issue
I have two functions, draw_ascii_spinner
and findCluster(companyid)
.
I would like to:
- Run
findCluster(companyid)
in the backround and while its processing.... - Run
draw_ascii_spinner
untilfindCluster(companyid)
finishes
How do I begin to try to solve for this (Python 2.7)?
Solution
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]
Answered By - Sven Marnach
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.