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

asyncmap #96

Closed
bjarthur opened this issue Apr 16, 2018 · 4 comments · May be fixed by #157
Closed

asyncmap #96

bjarthur opened this issue Apr 16, 2018 · 4 comments · May be fixed by #157

Comments

@bjarthur
Copy link

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.

@zsunberg
Copy link
Collaborator

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.

@yiyuezhuo
Copy link

yiyuezhuo commented Jul 7, 2021

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)

@gitboy16
Copy link

@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?

@MarcMush
Copy link
Collaborator

fixed by #322 with safe_lock=true (default is false if nthreads()=1)

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.

5 participants