Skip to content
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

Progress output is mangled when using async #253

Closed
arnaudh opened this issue Oct 31, 2022 · 3 comments · May be fixed by #157
Closed

Progress output is mangled when using async #253

arnaudh opened this issue Oct 31, 2022 · 3 comments · May be fixed by #157

Comments

@arnaudh
Copy link

arnaudh commented Oct 31, 2022

using ProgressMeter
progress = Progress(10);
asyncmap(1:10) do i
   sleep(i*0.1)
   next!(progress)
end

Output:

Progress:  20%|███████████▍                                             |  ETA: 0:00:04Progress:  30%|█████████████████▏                                       |  ETA: 0:00:03Progress:  40%|██████████████████████▊                                  |  ETA: 0:00:02Progress:  50%|████████████████████████████▌                            |  ETA: 0:00:01Progress:  60%|██████████████████████████████████▎                      |  ETA: 0:00:01Progress:  70%|███████████████████████████████████████▉                 |  ETA: 0:00:01Progress:  80%|███████████████████████████████████████Progress: 100%|█████████████████████████████████████████████████████████| Time: 0:00:01

Seems like the line doesn't get properly cleared/overriden when multiple calls to next!(progress) happen concurrently.

Note if I bump the sleep to a higher value (sleep(i)), the issue goes away:

Progress: 100%|█████████████████████████████████████████████████████████| Time: 0:00:10
  • Julia v1.8
  • ProgressMeter v1.7.2
@arnaudh
Copy link
Author

arnaudh commented Oct 31, 2022

Had a quick look at the code and documentation, seems like @showprogress can work with asyncmap, and a quick test shows the issue is not present in that case:

@showprogress asyncmap(1:10) do i
   sleep(i*0.1)
end

Output:

Progress: 100%|█████████████████████████████████████████████████████████| Time: 0:00:02

Sounds like this is the way to go.

Note I assumed my example (using ayncmap and next!) would be supported because of the note on thread-safety in the README (with the example using @threads and next!). Might be worth mentioning that asyncmap is only supported via @showprogress.

@MarcMush
Copy link
Collaborator

MarcMush commented Sep 3, 2023

The problem appears when two parallel tasks try to erase and write at the same time

Using next! with a ParallelProgress will be possible with #157

@MarcMush
Copy link
Collaborator

this should now work by forcing the lock (Progress(10; safe_lock=true)) (#322)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants