Closed kobusherbst closed 1 month ago
this seems like a job for #157 (not yet merged)
Progress(10; safe_lock=true)
might be enough for you though
otherwise a MWE would be useful to help you
Here is the MWE:
using ProgressMeter
function progress_example(node)
n = 25
p = Progress(n; desc="$(node) computing...", safe_lock=true)
for i in 1:n
sleep(rand(1:2))
next!(p)
end
finish!(p)
end
progress_example("Node A")
progress_example("Node B")
@sync begin
@async progress_example("Node C")
@async progress_example("Node D")
end
The first two calls display the "normal" expected behaviour, whereas the async calls show how the progress bars become interlaced. I am expecting (perhaps naively so) that the Node C and D progress bars will be updated in place as the async tasks progress.
]add ProgressMeter#5c21f5d
otherwise, you need the same lock for both progressbars and different offset:
using ProgressMeter
function progress_example(node, lock, offset)
n = 25
p = Progress(n; desc="$(node) computing...", safe_lock=true, lock, offset)
for i in 1:n
sleep(rand(1:2))
next!(p)
end
finish!(p)
end
@sync begin
lock = Threads.ReentrantLock()
@async progress_example("Node C", lock, 0)
@async progress_example("Node D", lock, 1)
end
Works perfectly, that you!
I have a situation like this:
The task displays a progress meter, created like this:
The output is interlaced with progress updated on multiple lines, rather than just on two lines.
How can I fix this please - wasn't sure how to use the Tips for parallel programming in the documentation in this case.