There are several tools for having a kind of "parallel ssh". As you use Python, pssh
should be fine. Install it with pip
:
$ sudo pip install pssh
Create a pssh hosts file like this:
192.168.0.10:22192.168.0.11:22
and then invoke:
$ pssh -h pssh-hosts -l root -A echo "Hi!"
You will asked for your password, but you can use certificates to avoid manual entering of passwords.
See more:
http://www.tecmint.com/execute-commands-on-multiple-linux-servers-using-pssh/
One important note: If you want to solve a problem in parallel, you may need MPI (Message Passing Interface). I suggest MPICH. MPI provides a standard means of communication to solve a problem collaboratively with multiple machines in parallel. Although, writing fast applications to find prime numbers/factors is nothing new.
If you have a multicore machine, use multithreading. But if you are going to use multiple computers, you will need MPI.