28 lines
542 B
Python
28 lines
542 B
Python
import random
|
|
import time
|
|
|
|
import scgenerator as sc
|
|
|
|
SIZE = 100
|
|
|
|
|
|
def compute_stuff(num: int, pbar: sc.threading.Multibar):
|
|
speed = random.random() * 5
|
|
for i in pbar(range(SIZE), desc=f"num {num}"):
|
|
time.sleep(0.05 * speed * random.random())
|
|
# if random.random() > 0.98:
|
|
# print(f"some text {i}")
|
|
return num
|
|
|
|
|
|
def main():
|
|
data = sc.threading.apply_with_progress(
|
|
compute_stuff, range(12), n_cpu=4, unpack=False, n_pertask=SIZE
|
|
)
|
|
|
|
print(data)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|