-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_progress.py
executable file
·55 lines (40 loc) · 1.13 KB
/
test_progress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import threading
import time
from multi_progress_bar import MultiProgressBar, __version__
# Create a progress bar
pb = MultiProgressBar()
print(f"Multi Progress Bar version {__version__}")
# Add some lanes
laneID1 = pb.add_lane(status="Task 1", total=100)
laneID2 = pb.add_lane(status="Task 2", total=50)
laneID3 = pb.add_lane(status="Downloading", total=0)
# Start the timed flush
pb.start_timed_flush()
def task1():
for i in range(1, 101):
pb.update(i, laneID1)
time.sleep(0.05)
def task2():
for i in range(1, 51):
pb.update(i, laneID2)
time.sleep(0.2)
def task3():
for i in range(1, 500):
pb.update_lane(laneID3, f"Downloading {i}", 0)
time.sleep(0.01)
pb.update_lane(laneID3, "Processing", 500)
for i in range(1, 500):
pb.update(i, laneID3)
time.sleep(0.01)
# Start the tasks in separate threads
thread1 = threading.Thread(target=task1)
thread2 = threading.Thread(target=task2)
thread3 = threading.Thread(target=task3)
thread1.start()
thread2.start()
thread3.start()
thread1.join()
thread2.join()
thread3.join()
pb.clear_all_lanes()
pb.timer_flag = False