ProgressMeter.jl
ProgressMeter.jl copied to clipboard
asyncmap
progressmeter.jl is awesome! works great for map, but sadly not asyncmap:
julia> using ProgressMeter
julia> prog = Progress(100)
julia> map(x->(sleep(1); next!(prog)),1:100) ### works!
Progress: 3%|█ | ETA: 0:02:43
julia> asyncmap(x->(sleep(1); next!(prog)),1:100; ntasks=1) ### works!
Progress: 5%|██ | ETA: 0:02:58
julia> asyncmap(x->(sleep(1); next!(prog)),1:100; ntasks=3) ### no worky :(
Progress: 7%|███ | ETA: 0:03:36Progress: 8%|███ | ETA: 0:03:07Progress: 9%|████ | Progress: 10%|████ | ETA: 0:02:36Progress: 11%|█████ | ETA: 0:02:20Progress: 12%|█████ | Progress: 13%|█████ | ETA: 0:02:02Progress: 14%|██████ | ETA: 0:01:52Progress: 15%|██████
any idea why it would print multiple progress bars for the asyncmap with multiple tasks, but not for that with a single task, or with map? thanks.
If the tasks are executing asynchronously, there is nothing to keep one task from starting to print while another is in the middle of printing.
See #109 for a possible solution.
A workaround without RemoteChannel:
prog = Progress(100)
ch = Channel{Nothing}(Inf)
task = @async begin
for _ in ch
next!(prog)
end
finished!(prog)
end
asyncmap(x->(sleep(0.2); put!(ch, nothing)),1:100; ntasks=3)
close(ch)
@yiyuezhuo , this seems to be working. However, do you have any idea why it takes a bit of time (hangs) after the progress bar has reached 100% to close the channel?
fixed by #322 with safe_lock=true (default is false if nthreads()=1)