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

task does not complete if saisei() is called before launching the server #47

Closed
wlandau opened this issue Apr 5, 2023 · 7 comments
Closed

Comments

@wlandau
Copy link

wlandau commented Apr 5, 2023

As I work on wlandau/crew#61, I notice that my tasks do not complete if the socket is switched with saisei() before the server connects.

library(mirai)
packageVersion("nanonext")
#> [1] ‘0.8.1.9006’
packageVersion("mirai")
#> [1] ‘0.8.2.9004’
packageDescription("mirai")$GithubSHA1
#> [1] "f74b480b1c7c33c700030ca1972aa9bee362cd8d"
daemons(n = 1L, url = "ws://127.0.0.1:5000", dispatcher = TRUE, token = TRUE)
#> [1] 1
task <- mirai(ps::ps_pid())
socket <- saisei(i = 1L)
px <- callr::r_bg(
  func = function() mirai::server(url = socket, asyncdial = FALSE),
  args = list(socket = socket)
)
Sys.sleep(10)
task$data
#> 'unresolved' logi NA
daemons(n = 0L)
@shikokuchuo
Copy link
Owner

shikokuchuo commented Apr 5, 2023

When I run this, this is because dispatcher doesn't load. I haven't investigated why yet, but if you simply use the launcher instead of callr, e.g.:

launch(sprintf("mirai::server(url ='%s',asyncdial=FALSE)", socket))

It works for me.

I am guessing 'socket' is not being passed correctly in callr and hence server() errors.
Yes, strangely enough, if I pass in the url manually without using 'args', it works in callr.

@wlandau
Copy link
Author

wlandau commented Apr 5, 2023

True, yes, my original error happened because socket was not an argument of the function I passed to callr. But I am having trouble with tasks failing to complete, as well as random crashes, on my local macbook. Tough to reproduce.

@wlandau wlandau closed this as completed Apr 5, 2023
@shikokuchuo
Copy link
Owner

I wonder if it is the socket locking mechanism - let me add another argument for that (off by default) so we can easily test it.

@shikokuchuo
Copy link
Owner

Try 8c77acb

I reverted a session finaliser I added. I also got a weird segfault running crew tests - malloc() double linked lists. This is definitely R rather than NNG.

@wlandau
Copy link
Author

wlandau commented Apr 5, 2023

Thanks for working on this. I tried that commit of mirai, and I am still consistently getting crashes running this test in RStudio. When I run it in the terminal and print out the value of daemons here, I always see 'errorValue' int 5 | Timed out after multiple calls to mirai::daemons() that run in quick succession.

@shikokuchuo
Copy link
Owner

When I run it in the terminal and print out the value of daemons here,

Right beneath your highlighted line, I see a reference to "status_online", which is now just "online".
Sorry for changing these around, but you might need to go through the tests to replace these.

@wlandau
Copy link
Author

wlandau commented Apr 5, 2023

I like the new names, it's not much trouble to make the switch in crew. I think they are all migrated in crew in subsequent commits. And I hope #48 helps make more sense of the errors and crashes I am reporting.

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