1import itertools
2import threading
3import time
4import sys
5
6done = False
7#here is the animation
8def animate():
9 for c in itertools.cycle(['|', '/', '-', '\\']):
10 if done:
11 break
12 sys.stdout.write('\rloading ' + c)
13 sys.stdout.flush()
14 time.sleep(0.1)
15 sys.stdout.write('\rDone! ')
16
17t = threading.Thread(target=animate)
18t.start()
19
20#long process here
21time.sleep(10)
22done = True