0

I have issues getting back a simple numpy array from a Pyro4 server (version 4.39, serializer= pickle) when its size exceeds a certain threshold. The server process the request and replies back but the client stays hanging

Code is below:

Server Code:

   import numpy as np, Pyro4

   class U(object):
       def __init__(self):
           self.Data = np.arange(10000000).reshape(200,50000)
           print self.Data.shape

       def get(self,name):
           print '%s Requested' % name
           return self.Data


   def run():
       Uni         = U()
       daemon      = Pyro4.Daemon(host='localhost')
       ns          = Pyro4.locateNS()
       uri         = daemon.register(Uni)
       ns.register("test",uri)
       print 'Up and waiting ...'
       daemon.requestLoop()

   if __name__ == '__main__':
       run()

Client Code:

   import Pyro4
   ns = Pyro4.locateNS()
   uri = ns.lookup('test')
   U=Pyro4.Proxy(uri)
   Data = U.get('Data')

Server Output: (200, 50000) Up and waiting ... Data Requested

So it seems the Pyro server process the request from the client and returns the data but the client never gets it and stay hanging indefinitely waiting to receive a message.

PS: - The same code work for a smaller size array (200,5000)

Does any one have a idea what could be the issue ?

Your help is much appreciated,

C.Rokos
  • 1
  • 1

1 Answers1

0

When I run it, the client stops with

Traceback (most recent call last):
  File "client.py", line 5, in <module>
    Data = U.get('Data')
  File "C:\python34\lib\site-packages\Pyro4\core.py", line 171, in __call__
    return self.__send(self.__name, args, kwargs)
  File "C:\python34\lib\site-packages\Pyro4\core.py", line 426, in _pyroInvoke
    raise data
TypeError: don't know how to serialize class <class 'numpy.ndarray'>. Give it vars() or an appropriate __getstate__
User
  • 14,131
  • 2
  • 40
  • 59
  • Need to change the serializer to pickle to get numpy working ... set PYRO_SERIALIZER='pickle' – C.Rokos Oct 07 '15 at 09:52
  • 1
    When I do `set PYRO_SERIALIZER=pickle` I get the error: `Pyro4.errors.NamingError: Failed to locate the nameserver` caused by `Pyro4.errors.CommunicationError: connection rejected, reason: message used serializer that is not accepted: 4`. Could you add more detail to your question, so that everyone can use it? Also consider sending a link to this question to the Pyro Mailing list. There you can get help, too. – User Oct 07 '15 at 10:06
  • Please read the Pyro documentation, there's a whole paragraph devoted to just this https://pythonhosted.org/Pyro4/tipstricks.html?highlight=numpy#pyro-and-numpy – Irmen de Jong Oct 09 '15 at 23:57