-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async task issue #331
Comments
this seems like a job for #157 (not yet merged)
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. |
#157 is perfect for that, you can use it with 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.
The text was updated successfully, but these errors were encountered: