i have a script/workframe that calls a function with the future package. The function does not return anything, but instead starts an API-Call, something like this:
library(future)
future::plan("multisession")
future_get_function = function (msg) {
link <- ("http://127.0.0.1:7774/echo?")
message <- list(msg=msg)
httr::GET(link, query=message)
Sys.sleep(20)
}
future::future({
future_get_function(msg)
}, globals = list(msg=msg)}
library(plumber)
#* Echo back the input
#* @param msg The message to echo
#* @get /echo
function(msg="") {
print("received something")
list(msg = paste0("The message is: '", msg, "'"))
}
Now, from what ive seen, I need to free up the processes that are done with the value function afterwards, correct? Otherwise, if I have more calls then processers/tasks available, they are stuck?
So is there a function that i can insert at the end of future_get_function or somewhere in the future call (promises would also be fine), that frees the process automatically once its done, without me having to call value or similar?
Thanks in advance.