-
Notifications
You must be signed in to change notification settings - Fork 10
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
"'errorValue' int 7 | Object closed" with transient sockets and transient workers #50
Comments
On my Macbook, I see |
You are getting those errors because you are using
I am sure this ties in with your needs as well. The above example just runs indefinitely now as |
Thanks for the safeguard! In my case, I cannot ignore the possibility that a worker suddenly connects between the time I check it and the time I try to rotate the path, so this is really helpful. Things on my end are working slightly better, although I am noticing a rare race condition where |
Could be somewhat related: this test does not call library(crew)
x <- crew_controller_local()
x$start()
x$router$poll()
d <- x$router$daemons
x$push(command = ps::ps_pid(), name = "task_pid")
x$wait(seconds_timeout = 5)
out <- x$pop(scale = FALSE)
stopifnot(!is.null(out)) # should not be NULL
x$terminate() |
You will only get 7 object closed if you close the socket at dispatcher (at the listener), as this is seen as intentional. |
That's what I thought. Looking at my original reprex from the top of the thread, I forgot to add library(mirai)
library(nanonext)
packageVersion("mirai")
#> [1] ‘0.8.2.9009’
packageVersion("nanonext")
#> [1] ‘0.8.1.9008’
daemons(n = 1L, url = "ws://127.0.0.1:5000")
count <- 0L
while (TRUE) {
count <- count + 1L
# Submit a new task.
m <- mirai("done")
# Try to rotate the websocket.
socket <- saisei(i = 1L)
# Wait for the previous server to disconnect and exit on its own.
start <- mclock()
while (!is.character(socket)) {
socket <- saisei(i = 1L)
if (mclock() - start > 5000) break
msleep(10)
}
stopifnot(is.character(socket))
# Launch the server with a fresh websocket.
launch(
sprintf(
"mirai::server(url = '%s', asyncdial = FALSE, maxtasks = 1L)",
saisei(i = 1L)
)
)
# Try to get the result of the task.
start <- mclock()
while (unresolved(m)) {
if (mclock() - start > 5000) break
msleep(10)
}
stopifnot(identical(m$data, "done"))
}
# State when I get "object closed":
socket
#> [1] "ws://127.0.0.1:5000/44317ae525dbbcbbd84c06467854758ea87ed1c7"
daemons()$daemons
#> online instance assigned complete
#> ws://127.0.0.1:5000/572271fb4da78b7a25859c9f00e3b8b7e66cfbcd 1 1 0 0
count
#> 2
m$data
#> 'errorValue' int 7 | Object closed
daemons(n = 0L) |
I fixed a bug in my example above, and now I am getting |
The loop logic needs a look, I think you mean something like: while (unresolved(m) || mclock() - start < 5000) Otherwise you risk calling |
Thanks, I changed the loop logic in the example below, and I am no longer getting "object closed" errors. Sometimes it runs for several iterations, but just now, the dispatcher exited at around library(mirai)
library(nanonext)
packageVersion("mirai")
#> [1] ‘0.8.2.9009’
packageVersion("nanonext")
#> [1] ‘0.8.1.9008’
daemons(n = 1L, url = "ws://127.0.0.1:5000")
count <- 0L
while (TRUE) {
count <- count + 1L
# Submit a new task.
m <- mirai("done")
# Try to rotate the websocket.
socket <- saisei(i = 1L)
# Wait for the previous server to disconnect and exit on its own.
start <- mclock()
while (!is.character(socket) || mclock() - start < 5000) {
socket <- saisei(i = 1L)
msleep(10)
}
stopifnot(is.character(socket))
# Launch the server with a fresh websocket.
launch(
sprintf(
"mirai::server(url = '%s', asyncdial = FALSE, maxtasks = 1L)",
saisei(i = 1L)
)
)
# Try to get the result of the task.
start <- mclock()
while (unresolved(m) || mclock() - start < 5000) {
msleep(10)
}
stopifnot(identical(m$data, "done"))
} |
So I found out #51 is part of the reason for "object closed" errors, but it is not the whole reason. If I run the following test in branch library(crew)
x <- crew_controller_local(tasks_max = 1L)
x$start()
n <- 4
for (index in seq_len(4L)) x$push(command = ps::ps_pid())
x$wait()
results <- list()
while (length(x$results) > 0L || length(x$queue) > 0L) {
out <- x$pop()
if (!is.null(out)) results[[length(results) + 1L]] <- out
}
results <- tibble::as_tibble(do.call(rbind, results))
results$result <- as.integer(results$result)
results$error
View(x$summary())
x$terminate() |
Hmm... maybe that's not right either, I tried suppressing launches when the |
I was going to suggest using the 'connections' column at So just to clarify, you are still getting 7 Object closed? |
Thanks for continuing to work on this. I am still getting "object closed", both with 0.8.2.9000 and 0.8.2.9011. Here is a reprex that uses only library(mirai)
library(nanonext)
daemons(n = 1L, url = "ws://127.0.0.1:5000", dispatcher = TRUE, token = TRUE)
msleep(5000)
tasks <- lapply(seq_len(2), function(x) mirai("done"))
while (any(vapply(tasks, unresolved, FUN.VALUE = logical(1L)))) {
socket <- saisei(i = 1L)
if (!is.null(socket)) {
command <- sprintf(
"mirai::server(url = '%s', asyncdial = FALSE, maxtasks = 1L)",
socket
)
launch(command)
}
msleep(1000)
}
tasks[[1]]$data
#> [1] "done"
tasks[[2]]$data
#> 'errorValue' int 7 | Object closed
daemons(n = 0L) |
The above now works with v0.8.2.9012. |
As I mentioned in #48 (comment), when I work on wlandau/crew#61 and test crew transient workers, I notice a lot of
"'errorValue' int 7 | Object closed"
(about 50% of tasks in that test). The following example reproduces the same issue (at least on my Ubuntu machine) with justmirai
andnanonext
. I think it has something to do with the fact that I am using transient single-task workers and recycling the websocket withsaisei()
after each task.The text was updated successfully, but these errors were encountered: