D
D
Dmitry Sobolev2020-11-08 15:50:14
Python
Dmitry Sobolev, 2020-11-08 15:50:14

What is the best way to send code from the raspberry server to raspberry clients, execute it and return the result to the server?

Got my thesis. Essence:
There are 3 raspberries, one will be as a server, and the other two as clients. From the server, you need to send the code for execution to clients. Moreover, it can be any task that can be solved in parallel. The client does not have to know the code in advance, the server will send it to him. When the client(s) performs the calculations, it will return the result(s) to the server. Of course, if there is some kind of error, then it should come to the server and write what happened and from which client.

Is it possible to solve this problem using Python and socket?
Or maybe it's better to look towards rabbitmq ?
I also read that if dispy is just for this intended. But I haven't figured out if it will work or not yet.

What do you recommend to use?
What should the server side and client side look like in order to pass an entire executable function? in words, algorithmically

I seem to understand the task. I started to deal with sockets, but how then to send what I need to a specific client? After all, the program for execution by the client can be 10-30 lines of code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-11-08
@shurshur

rabbitmq is just a way to exchange data, it will not solve the task by itself. But dispy, judging by the description and examples from the documentation, may be suitable for such tasks, I would try.
If you want to build your own solution, then sockets, in principle, are not so necessary (although they can also be used for interaction). You can, for example, make a web service in which to transfer a file with code or even an archive with code and data. On the other side, the handler will put it all in a temporary directory, run it when the calculations are completed - the result will be merged back to the server. Something like this:
The server calls:
POST computational-node1/task
..code and/or data..

we get in response some id - task identifier - for example, 123.
After that, the node starts the computational process. At its end, the server jerks:
POST main-server/result/computational-node1/123
..results..

Another option is to upload the task also as an archive via scp, then call the script via ssh and wait for its completion.
There are dozens of variations in the thickness and bending radius of the crutches.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question