The answer to this one is simple (but not so easy to implement):
- Write a Python program to be executed on each machine.
- Write a (bash / shell) script that connects to your machines via SSH and starts the Python programs. You’ll need the IP addresses of all your machines.
- Use Python socket connections (based on the TCP protocol) to allow your Python programs to send each other TCP messages. You’ll need the IP addresses of all your machines again.
- Sending messages via TCP is a synchronous communication: your program blocks until it receives the response. If you want to make your program non-blocking, you can create separate threads that handle the sending and receiving of messages and execute “callback” functions in your main Python program. You can study multi-threading in Python.
This is how I would do it at least. I’m sure there are plenty of other ways to accomplish the same thing—but most of them will build upon TCP communication anyway.