{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl/issues/138","repository_url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl","labels_url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl/issues/138/labels{/name}","comments_url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl/issues/138/comments","events_url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl/issues/138/events","html_url":"https://github.com/JuliaGizmos/Reactive.jl/pull/138","id":228537574,"number":138,"title":"Fixes issue when runner task is restarted during a push","user":{"login":"JobJob","id":854183,"avatar_url":"https://avatars0.githubusercontent.com/u/854183?v=3","gravatar_id":"","url":"https://api.github.com/users/JobJob","html_url":"https://github.com/JobJob","followers_url":"https://api.github.com/users/JobJob/followers","following_url":"https://api.github.com/users/JobJob/following{/other_user}","gists_url":"https://api.github.com/users/JobJob/gists{/gist_id}","starred_url":"https://api.github.com/users/JobJob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JobJob/subscriptions","organizations_url":"https://api.github.com/users/JobJob/orgs","repos_url":"https://api.github.com/users/JobJob/repos","events_url":"https://api.github.com/users/JobJob/events{/privacy}","received_events_url":"https://api.github.com/users/JobJob/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-14T12:10:42Z","updated_at":"2017-05-15T06:12:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl/pulls/138","html_url":"https://github.com/JuliaGizmos/Reactive.jl/pull/138","diff_url":"https://github.com/JuliaGizmos/Reactive.jl/pull/138.diff","patch_url":"https://github.com/JuliaGizmos/Reactive.jl/pull/138.patch"},"body":"I've run into some issues with signals not updating recently, and I was hoping #137 was going to fix them, but it hasn't seemed to. \r\n\r\nThanks to the simple reproduction in https://github.com/JuliaGizmos/GtkReactive.jl/issues/32 I was able to pin it down to situations where the queue runner task is restarted from the queue runner task itself. This will happen if add_action! is called while processing a push!. E.g. if a new map/foreach is added as part of the function of another map/foreach.\r\n\r\nE.g. after running this\r\n```\r\nusing Reactive\r\nqueue_size() =  Base.n_avail(Reactive._messages)\r\na = Signal(1)\r\nb = Signal(2)\r\nforeach(a; init=nothing) do _\r\n    foreach(b; init=nothing) do _\r\n        println(\"b was updated\")\r\n    end\r\n    println(\"added a foreach on b\")\r\n    nothing\r\nend\r\n```\r\ncalling `push!(a,3)` (multiple times) was not leading to the \"added a foreach on b\" to be printed. Then running this showed there were actions unprocessed in the queue:\r\n```\r\n@show queue_size()\r\nReactive.run_till_now()\r\n@show queue_size()\r\n```\r\nshows\r\n```\r\nqueue_size() = 3\r\nqueue_size() = 2\r\n```\r\nworse still calling `run_till_now()` again causes the queue to get stuck - I think on [this line](https://github.com/JuliaGizmos/Reactive.jl/blob/master/src/core.jl#L377) , waiting on itself.\r\n\r\nAnyway this PR fixes that. There's probably a neater way to do the restart, but I personally don't have that much time to spare for it right now. It would need to handle the case of multiple `add_action!` calls while processing the same `push!`. Anyway, I've added some tests for this so if someone has a better idea they can try it out.\r\n\r\nIt the meantime, barring someone noticing any obvious problems, I think we should merge this asap, because it came up pretty fast for me when getting back to doing some stuff with Interact in the last few days, as well as in the GtkReactive bug mentioned above - so I think it's a fairly major bug.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl/issues/comments/301385012","html_url":"https://github.com/JuliaGizmos/Reactive.jl/pull/138#issuecomment-301385012","issue_url":"https://api.github.com/repos/JuliaGizmos/Reactive.jl/issues/138","id":301385012,"user":{"login":"JobJob","id":854183,"avatar_url":"https://avatars0.githubusercontent.com/u/854183?v=3","gravatar_id":"","url":"https://api.github.com/users/JobJob","html_url":"https://github.com/JobJob","followers_url":"https://api.github.com/users/JobJob/followers","following_url":"https://api.github.com/users/JobJob/following{/other_user}","gists_url":"https://api.github.com/users/JobJob/gists{/gist_id}","starred_url":"https://api.github.com/users/JobJob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JobJob/subscriptions","organizations_url":"https://api.github.com/users/JobJob/orgs","repos_url":"https://api.github.com/users/JobJob/repos","events_url":"https://api.github.com/users/JobJob/events{/privacy}","received_events_url":"https://api.github.com/users/JobJob/received_events","type":"User","site_admin":false},"created_at":"2017-05-15T06:12:05Z","updated_at":"2017-05-15T06:12:05Z","body":"The travis failure is the same weird issue with loading linalg libs as on #137 \r\nIs everyone/anyone happy for me to merge this and tag a new version?"}}
{"actor":{"display_login":"JobJob"}}