Metaclass >> How to access methods of <netref class 'numpy.ndarray'> ?

521 views
Skip to first unread message

baco

unread,
Jun 25, 2012, 8:35:37 AM6/25/12
to rp...@googlegroups.com
Hi all,
I have a <netref class 'numpy.ndarray'> object (server side) and I can't access to any of method (in particular the .tostring()). 
Data from this object is ok, but need to have the 'real' numpy.ndarray from my client, to use it.
thanks for help
-baco

Tomer Filiba

unread,
Jun 25, 2012, 11:54:15 AM6/25/12
to rp...@googlegroups.com
you'd have to provide a code snippet that reconstructs the problem.

but if ultimately need to copy the ndarray from one process to another (passing it by value),

-----------------------------------------------------------------
    
Tomer Filiba 
tomerfiliba.com        

baco

unread,
Jun 25, 2012, 12:49:35 PM6/25/12
to rp...@googlegroups.com
thanks again for your huge work around RPyC and support.
I will try the obtain method

By the way,
my RPyC tests project is to have two servers: 
-One to get photo from webcam/camera (via opencv) => WebCamService
-Andd another server for update a wxPython Gui (with wxStaticBitmap => GuiService
In the middle of this two servers a client which launch both servers and get an image through a exposed_function   "def exposed_GetPhoto(self)" of webcamService (use service like this in my client "webcam=cWebcam.root.last_photo").
At this point the webcam is a <netref class 'numpy.ndarray'> but I get use any tostring(), copy() method from numpy without problem...
But when I send 'webcam' to my Gui server through a exposed_function "def exposed_SetPhoto(self,photo)" of my RPyC GuiService, I can visualize the ndarray but I can't use methods on it (server side°

I hope, my explanation was clear.

best regards,
-damien 


Le lundi 25 juin 2012 17:54:15 UTC+2, Tomer Filiba a écrit :
you'd have to provide a code snippet that reconstructs the problem.

but if ultimately need to copy the ndarray from one process to another (passing it by value),

-----------------------------------------------------------------
    
Tomer Filiba 
tomerfiliba.com        


baco

unread,
Jun 28, 2012, 3:46:13 AM6/28/12
to rp...@googlegroups.com
Hi Tomer,
I rewrite some code to show the problem, I described below:
-s1.py : the service server to get array info asked by client.py
-s2.py: the gui: show information send by client.py
-client.py: get information from any device/source info, compile and use an remote GUI to show info

Again, the aim of this project is to get infos from devices servers, compile info in client.py then send infos to some gui server.

Clearly this example have no sense, but only show the error about the access to the method tostring().
Hope it helps !

####s1.py
'''
Server 1 : serve an array
'''
import rpyc,sys
from rpyc.utils.server import ThreadedServer
import numpy as np

class ArrayService(rpyc.Service):        
  def exposed_GetArray(self):
    array=np.array([[1,2,3],[4,5,6]])
    return array
if __name__ == "__main__":
  if len(sys.argv)==2: port = int(sys.argv[1])
  else: port = 2222
  server = ThreadedServer(ArrayService, port = port,hostname="localhost",protocol_config={'allow_all_attrs':True})
  server.start()


####s2.py
'''
Server 2  Gui for Array
'''
import rpyc,sys
from rpyc.utils.server import ThreadedServer
#import numpy as np
import numpy as np

class WatchService(rpyc.Service):        
  def exposed_ShowArray(self,array):
    print array.tostring() #it fails!
    return True
if __name__ == "__main__":
  if len(sys.argv)==2: port = int(sys.argv[1])
  else: port = 2223
  server = ThreadedServer(WatchService, port = port,hostname="localhost",protocol_config={'allow_all_attrs':True})
  server.start()


#####client.py
# -*- coding: UTF-8 -*-
'''
Client get from Server1 (s1.py) to Server2 (s2.py)
'''
import rpyc,time,subprocess,os,signal

proc=[]
proc.append(subprocess.Popen(r"python .\s1.py "+str(2222),  bufsize=-1, creationflags = subprocess.CREATE_NEW_CONSOLE).pid)
proc.append(subprocess.Popen(r"python .\s2.py "+str(2223),  bufsize=-1, creationflags = subprocess.CREATE_NEW_CONSOLE).pid)
time.sleep(1)
Server1=rpyc.connect("localhost",2222)
Server2=rpyc.connect("localhost",2223)

array=Server1.root.GetArray()
print array.tostring() #it works!
Server2.root.ShowArray(array)
for i in range(len(proc)):
  time.sleep(0.1)
  print "kill ",proc[i],'   ',os.kill(proc[i],signal.SIGTERM )==None



regards,
-damien

Le lundi 25 juin 2012 17:54:15 UTC+2, Tomer Filiba a écrit :
client.py
s1.py
s2.py

Enrique Soto Mendoza

unread,
Nov 16, 2015, 8:40:18 PM11/16/15
to rpyc, damien...@gmail.com
Hi baco, 

I'm stucked in the same issue. Did you overcome it? 
Thanks

Hamza Anis

unread,
Jun 4, 2018, 5:16:42 AM6/4/18
to rpyc
Do someone know what's the problem here. Why object is changing to netref?

Hamza Anis

unread,
Jun 4, 2018, 4:53:03 PM6/4/18
to rpyc
If some one has the same issue. Refer to this issue #154
Reply all
Reply to author
Forward
0 new messages