SvSocket evalServer wait process

Problem Version 1, Can we force the pr_fun process to reconfigure it without waiting for ch_fun () to complete

ch_fun <- function() {Sys.sleep(10)} pr_fun <- function() {ch_fun(); return("Done")} pr_fun() 

Actual Bypass Version

R session 1 as svSocket server

 library(svSocket) startSocketServer(port = 9875,local=FALSE) 

R session 2 as svSocket client

 con <- socketConnection(port = 9875,host="127.0.0.1") evalServer(con,"Sys.sleep(20)") 

R session 3 as svSocket client

 con <- socketConnection(port = 9875,host="127.0.0.1") evalServer(con,"a=10") 

If we run the lines of code for session 2, and while processing the Sys.sleep server, the server quickly translates the lines of code for session 3 into session 3 and interrupts the call that is still being processed. We can check this on the server side by checking if the object "a" was created.

My point is that we did not have to wait for the completion of work in session 3, but it was processed, so some tasks were grouped on the side of the session, and we do not need to wait for the completion of tasks to just send them to the server and interrupt the waiting process and move forward. We can manually interrupt the use of Ctrl + C or Esc, but how can I do this in a function. I want pr_fun to call ch_fun in a server session and return immediately to it.

+5
source share

Source: https://habr.com/ru/post/1264407/


All Articles