[Numpy-discussion] xml-rpc with numpy arrays

Brian Blais bblais@bryant....
Tue Sep 30 12:53:05 CDT 2008


Hello,

I am trying to use xml-rpc to be able to run some simulations  
remotely.  I am running into a problem with the transfer of numpy  
arrays.  my server code looks like:

#!/usr/bin/env python
def again(x):  # test out the sending of data
     return [x,x]


from SimpleXMLRPCServer import SimpleXMLRPCServer
SimpleXMLRPCServer.allow_reuse_address = 1

server = SimpleXMLRPCServer(("", 8000))

server.register_function(again)
try:
     print "Serving..."
     server.serve_forever() # Start the server
finally:
     print "done."
     server.server_close()



my client code looks like:

import numpy
from xmlrpclib import ServerProxy
server=ServerProxy('http://localhost:8000')
server.again(5)  # this works

b=numpy.random.rand(5,5)

server.again(b)  # this gives an error

this gives the error: <type 'exceptions.TypeError'>: cannot marshal  
<type 'numpy.ndarray'> objects

which seems to be a deficiency of the marshal library, or perhaps I  
am doing something wrong.  Is there a way to fix this?  Is there  
another approach that I should be using?


		thanks,

			Brian Blais

-- 
Brian Blais
bblais@bryant.edu
http://web.bryant.edu/~bblais



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080930/507f95b6/attachment.html 


More information about the Numpy-discussion mailing list