i need an advice over how to set up streaming responses from node js server to python, from python back to node js.
There are four files a) The node js script b) The serverConn.py script c) The python file that takes input from serverconn.py script called count.py d) the python file that takes input from count.py and return it back to serverConn to be sent back to the node.js server
I read up on zerorpc and i am currently using it to send input from the node js to python, but the python script also has to send the input to another python script, and that python script also has to send the input to another python script and then send the result back to the node js server.
Everything seems complicated for someone who just got out of college lol.
I saw this thread and was also wondering if i could use something like this for the two python scripts to communicate with each other.
How to get a python script to listen for inputs from another script
This is my node js script
var server = new zerorpc.Server({
hello: function(name, reply) {
var catalog = "3D";
reply(null, catalog + name);
}
});
server.bind("tcp://0.0.0.0:4244");
And this is my python script
import zerorpc
class serverConn:
def __init__(self):
self.c = "tcp://127.0.0.1:4244"
def client(self):
c = zerorpc.Client()
c.connect(self.c)
catalog = c.hello("")
return catalog
s = serverConn()
s.client()
The python script gets the input from the node js file, and sends it to matchcount.py file, and matchcount.py sends it to calculate.py file, and calculate.py file sends it back to node js.
Is there any tips on how i can go about this, and will the link i posted help?
Thank you.
Ok so you have nodejs -> python #1 -> python #2 -> python #3. The nodejs process is a client only. Python #1 and #2 are servers and clients to the next python process. Python #3 is a server only.
Thus your nodejs process should use a zerorpc client to invoke a given procedure on python #1. Python #1 will run a zerorpc Server with the procedure. In turn this procedure will use a zerorpc client and so on. When the last process returns from it's procedure, zerorpc will return the value back to the caller process. If each of your procedure always return the result of the remote procedure call. The result will eventually come back to the nodejs process.