Using mongolite connection in a forked process ?
Closed this issue · 0 comments
ncullen93 commented
Is it possible to create a mongo connection in a forked process? It seems to give an error. The only reprex I have is based on the RestRserve api framework.
library(RestRserve)
library(mongolite)
fetch_models_handler <- function(req, res) {
conn <- mongolite::mongo(collection, db, url)
# then, eventually make a find() call and disconnect
# adding conn$disconnect() doesnt help
}
app = Application$new(
content_type = "application/json"
)
app$add_get(
path = "/fetchModels",
FUN = fetch_models_handler
)
backend = BackendRserve$new()
backend$start(app, http_port = 8080)
This framework creates a forked process for each request, hence the error.
It leads to this error:
objc[2671]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.