How to correctly spawn a process (mcparallel
) from inside a RestRserve
end point?
#217
Unanswered
dereckmezquita
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I ran into an interesting problem recently: how to spawn a parallel independent process from a RestRserve end point.
Related: #216
I am not an expert in
parallel
norRestRserve
's internals, my goal here is to start a discussion and get a better understanding. I want to get a deeper understanding so to better debug in the future.The problem and miminal example:
segfault
/permission errorsI was encountering segmentation faults when using
parallel
andlater
packages together within a RestRserve endpoint. Setting thedetached
argument toTRUE
in themcparallel
function seems to have resolved the immediate issue.Here is a minimal example:
Observations and solution:
mcparallel(detached = TRUE)
parallel
alone in the endpoint worked without segfaults and without needing thedetached
argument:parallel
withlater
, usingdetached = TRUE
seems to prevent errors:Discussion
While this solution appears to work for now, I'm concerned that I might have gotten lucky in solving this and could encounter more issues down the line. I'm seeking expert insights and explanations on the following points:
detached = TRUE
:Can someone explain why using
detached = TRUE
resolves the segmentation fault? What's happening under the hood?How does RestRserve's request handling (which involves forking) interact with the processes we're creating manually? Are there potential conflicts or race conditions? I know that RestRserve itself uses
parallel
.Is this a reliable approach for production use? Are there scenarios where it might break or cause unexpected behavior?
What are the performance implications of using detached processes within RestRserve endpoints? How might this affect the application's scalability?
Are there best practices for handling asynchronous operations or spawning processes in RestRserve? Are there alternative approaches that might be more robust or efficient?
What kind of issues might I encounter in the future with this approach? Are there any specific areas I should be cautious about?
Thank you very much and I hope to contribute some of my experience for those wanting to do something similar.
Beta Was this translation helpful? Give feedback.
All reactions