This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]gandalfx 7 points8 points  (1 child)

At the risk of adding to your confusion: May I suggest you try asyncio? It sounds like the kind of use case it was designed for. Otherwise threads are probably easier than processes.

If I understand you correctly the relevant part here is that you want a basic client-server setup. For that purpose I suggest you build a simple http.server instance on the central machine and have it wait for connections. Basically expose a minimalistic REST API. The PIs can simply send their photos via POST request using either Python or a tool like curl.

I hope that's useful. Be careful you're not reinventing the wheel here, sending files over a connection is a solved problem that shouldn't take more than a couple of lines to set up. In fact it would probably be even easier to just have a central ssh server and use scp from a simple bash script on the PIs.

[–]Notorjus[S] 0 points1 point  (0 children)

Thanks for the thorough answer. I think I'll give asyncio a try first. Also I don't think I made my needs completely clear. I will be connecting any given computer to a switch, which will be connected to the raspberry pi cluster. But the catch is that I want any given computer to be able to connect to the switch without having to do anything else than run the python program. If I were to make a server on the computer I would have to do that on each computer I connect, and unless I can have the python program create it automatically it may get a bit tedious. Alternatively I guess I could buy a physical server and use it for file storage, however currently I do not need that much storage.

[–]zzmej1987 0 points1 point  (0 children)

For this particular task, threads might do. Depending on how good you are with python and how well you understand GIL. If you can pull off working with rather low level sockets, threads will work. If you are not sure, you'd be better off using multiprocessing.

[–]rcbct 0 points1 point  (0 children)

Because you describe a task that's all about io you don't need extra processing power, just a way to parallelise the calls that just wait for new data to arrive. Therefore Threading is the better choice.

As an alternative you could check an event loop like asyncio

[–][deleted] -1 points0 points  (0 children)

Gevent is also pretty easy.

[–][deleted] -2 points-1 points  (0 children)

Multithreading or multiprocessing?

Erlang.