-
Notifications
You must be signed in to change notification settings - Fork 7
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
Forwarding to ephemeral condition variables #24
Comments
May be a bit clunky, but this at the moment is how it works: library(nanonext)
cv1 <- cv()
f <- function(cv1) {
cv2 <- cv()
cv1 %~>% cv2
until(cv2, 50)
attr(cv1, "cv") <- NULL
gc(verbose = FALSE)
}
for (i in 1:100) {
print(i)
f(cv1)
} |
Thanks for explaining, that definitely avoids problems with my R session hanging. My only concern is the need to call |
Also, in my case, |
On the other hand, maybe I won't need ephemeral CVs if I go with my original plan in wlandau/crew#108 (comment). That might be more robust anyway, if I have nextget("cv") forward to controller-specific CVs and then have those CVs forward to a controller group. |
Avoiding the gc call should be trivial, but forwarding to more than one cv might involve more complexity than it's worth... what you describe above sounds more robust. |
I'm posting a commit which fixes your original issue so that your initial code block runs. If you want to pursue forwarding to multiple cvs pls do open another issue. Probably not impossible, but the forwarding mechanism wasn't designed with this intention at the outset. |
Thanks, @shikokuchuo! I think I figured out a relaying pattern which does not require forwarding to multiple CVs. I will let you know how its goes. |
Happy to report that I have completed wlandau/crew#108 and the new tests are passing. I initially struggled with intermittently hanging |
Currently having issues with my other throughput tests though (Ubuntu, https://github.com/wlandau/crew/blob/main/tests/throughput/test-backlog-seconds_idle.R, https://github.com/wlandau/crew/blob/main/tests/throughput/test-backlog-tasks_max.R). I am looking into it to see if it is something to do with |
@shikokuchuo, here is a library(mirai)
library(nanonext)
library(purrr)
n <- 20L
daemons(n = n, url = "ws://127.0.0.1:5700")
tasks <- replicate(60000, mirai(TRUE))
while(remaining <- sum(map_lgl(tasks, ~.unresolved(.x)))) {
message("Waiting for ", remaining, " tasks.")
stats <- status()$daemons
for (index in seq_len(n)) {
if (!stats[index, "online"]) {
launch_local(
url = rownames(stats)[index],
maxtasks = 100
)
}
}
stats <- status()$daemons
Sys.sleep(2)
} |
Restarting my R session in RStudio after running the test above resulted in a crash. |
Odd, when I downgraded to |
I can't reproduce your hang and I develop on Ubuntu as you know. Recent Rstudio upgrades without clearing old config files have caused issues for me - you could try that. Or simply run at an R prompt not using rstudio. |
Not only does your mirai-only example run fine (every time), but I just tested all your updated crew tests (build b336368), including the 2 throughput (backlog) ones you mention above, and they also complete fine, on Ubuntu. I'm going to assume you just ran into some configuration issues, unless you can provide more specifics. |
The throughput tests issue was solved via shikokuchuo/mirai@d7b4f59, as confirmed here: wlandau/crew#138 (reply in thread). |
For controller groups in
crew
, I would like to be able to wait on an ephemeral condition variable which gets signals from%~>%
and whose lifespan is a call to a function. When I simulate many such calls, my R session becomes unresponsive.The text was updated successfully, but these errors were encountered: