I am new to node.js and in the position where I am using Node.js for a single page app. I have to occasionally do some very complex data manipulation (for AI and statistical functions). These services are written in Python. I am trying to figure out the best way to hand off these computations to a child process so my main thread is not blocked and I can use the abundance of python libraries available.
I need to be able to pass complex data (a JSON object is fine) to the child process and receive complex output (again a JSON object is ideal). Referring to Node.js math computation - child process and complex data?, this is simple enough with another node.js process using child_process.fork() and .send().
Is there a similar method in child_process.spawn()? Or is it possible to use .fork() to execute a python script. All I can figure out is how to execute system commands which don't allow but the most simple arguments. Even if I can send the data, I am unclear about how to receive data using .spawn().
I couldn't find this answer on SO, but I admit node.js is new to me.
Thank you.