[IPython-user] cluster file syntax

Fernando Perez Fernando.Perez at colorado.edu
Thu Mar 16 12:29:11 CST 2006


Jonathan Taylor wrote:
> hi,
> 
> i've been playing with the ipkernel demos and was curious about
> the format of the "cluster_*" files.
> 
> it seems they're binary (at least the example i have is). while they're 
> small, i was
> curious how one goes about creating their own...

pickle.load(open(filename))

will show you that it's just a pickle of a list of the form

[('100.100.100.100',99),
('100.100.100.101',99),
('100.100.100.102',99)]

where each entry is a tuple of (IP address,port number), which is the standard 
format for socket connections.  So creating one is as simple as:


In [1]: import pickle

In [2]: cluster = 
[('192.168.0.10',10105),('192.168.0.11',10105),('192.168.0.12',10105),('192.168.0.13',10105)]

In [3]: pickle.dump(cluster,file('test_cluster','w'))


Cheers,

f




More information about the IPython-user mailing list