Closed thomasdziedzic closed 3 years ago
@thomasdziedzic, thank you for your question.
Can you try the following code? It works in my environment.
import multiprocessing
from atpbar import atpbar, register_reporter, find_reporter, flush
import more_itertools
multiprocessing.set_start_method('fork', force=True)
def f(xs):
count = 0
for x in atpbar(list(xs), name = multiprocessing.current_process().name):
count += 1
return count
items = range(80000000)
workloads = more_itertools.divide(8, items)
reporter = find_reporter()
with multiprocessing.Pool(8, register_reporter, [reporter]) as p:
ret = p.map(f, workloads)
flush()
print(sum(ret))
I see progress bars like below.
12.87% ::::: | 1287216 / 10000000 |: ForkPoolWorker-8
12.98% ::::: | 1297716 / 10000000 |: ForkPoolWorker-1
12.91% ::::: | 1291065 / 10000000 |: ForkPoolWorker-3
12.96% ::::: | 1295941 / 10000000 |: ForkPoolWorker-6
13.05% ::::: | 1304935 / 10000000 |: ForkPoolWorker-5
12.73% ::::: | 1272576 / 10000000 |: ForkPoolWorker-2
12.69% ::::: | 1269152 / 10000000 |: ForkPoolWorker-4
12.82% ::::: | 1282320 / 10000000 |: ForkPoolWorker-7
Thanks that worked!
I have the following example code:
This gives me: