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

Asynchronous concurrency gets Reduce confused #52

Open
dstahlke opened this issue Jul 5, 2021 · 2 comments
Open

Asynchronous concurrency gets Reduce confused #52

dstahlke opened this issue Jul 5, 2021 · 2 comments

Comments

@dstahlke
Copy link

dstahlke commented Jul 5, 2021

The following test works. But take out the Semaphore and it hangs and/or scrambles the results. Perhaps Reduce.jl should be using a semaphore/mutex internally? This problem arose when I was using Reduce.jl with Genie.jl, and it caused some hard to debug problems, such as one HTTP request hanging until the next request came in, or having rcall return the result from someone else's query.

using Reduce

reduce_sem = Base.Semaphore(1)

println("create")
tasks = []
for i in 1:10
    t = @task begin
        println("begin $i")
        Base.acquire(reduce_sem)
        println("rcall $i")
        y = :($i * x) |> rcall
        println("$i -> $y")
        Base.release(reduce_sem)
        println("released")
    end
    push!(tasks, t)
end

println("schedule")
for t in tasks
    schedule(t)
end

println("wait")
for t in tasks
    wait(t)
end
@chakravala
Copy link
Owner

Thanks for the interest in my project, I don't currently have time to look into this issue as it's not relevant to my own usage.

If you'd like me to look into it further, please consider sponsoring me to work on this issue and provide more details.

@dstahlke
Copy link
Author

dstahlke commented Jul 5, 2021

For now the Semaphore workaround works for me. Perhaps I will one day find time to find a fix and send you a pull request.

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

No branches or pull requests

2 participants