multi-pbar threading

This commit is contained in:
2024-02-06 08:59:34 +01:00
parent 400ae2fd48
commit ab2f90184f
9 changed files with 392 additions and 11 deletions

View File

@@ -0,0 +1,22 @@
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}")
def main():
sc.threading.apply_with_progress(compute_stuff, range(12), n_cpu=4, unpack=False)
if __name__ == "__main__":
main()