I should add that:
- the error in dummy.print2 is solved if I set allow_public_attrs = True
for my server
But still:
How is that dummy.dummy(d) takes 10^5 longer when run by the service?
(no network issue here, as everything is on my localhost)
On Tuesday, January 22, 2013 4:24:50 PM UTC+1, Boris wrote:
>
> Hi rpyc users and developpers!
>
> (cf my code below as I can not attach files...)
>
> I am building a big dummy dictionary, and call a dummy function on it that
> loops through all keys and sets the values to 0.
> This function takes 0.00099 seconds.
>
> If run by a rpyc.service (that runs on the same host), it takes 9.346
> seconds.
> Also, it looks like the execution of the body of the function exposed by
> the service will start even if the input object "sent" by the client has
> not been "received" entirely on the server side. Cf in my code:
> dummy.print1 will fail (trying to perform a for k,v in d.items).
>
> Thus my questions:
> - Is there a connection param I could use to speed up the transmission of
> a big object between my client and my service? (typically a 150kB object
> when pickled)
> - How is it that the function run by the service starts its execution
> while the function input is not available yet?
>
> Thanks a lot for your comments/suggestions, and the great work on rpyc,
> Boris
>
> **************** mini_service.py ******************************************
>
> ******************************************************************************
> import rpyc
> from rpyc.utils.server import ThreadedServer
> import dummy
>
> class miniService(rpyc.Service):
> def exposed_myfunc(self,d):
> #dummy.print1(d) #success
> #dummy.print2(d) #Netref.py / protocol.py / AttributeError: cannot access
> 'items'
> dummy.dummy(d)
>
> if __name__=='__main__':
> t = ThreadedServer(miniService,protocol_config = {"allow_pickle" : True},
> port = 19865)
> t.start()
>
> ********************* mini_client.py **************************************
>
> ******************************************************************************
> import rpyc
> import sys
> #import socket
> import pickle
> import dummy
> def makedict(n):
> d={x:x for x in range(n)}
> return d
>
> if __name__ == "__main__":
> d=makedict(20000)
> print(sys.getsizeof(d)) #result = 393356
> # dummy.print2(d)
>
> # output = open("C:\\rd\\non_mc_test_files\\mini.pkl",'wb') #117kB object
> for n=20k
> # pickle.dump(d,output)
> # output.close()
>
> #RUN1 : dummy.dummy(d) out of rpyc takes 0.00099 seconds
> # dummy.dummy(d)
>
> #RUN2 : dummy.dummy(d) via RPYC on localhost takes 9.346 seconds
> # conn=rpyc.connect('localhost',19865,config={"allow_pickle":True})
> # conn.root.myfunc(d)
>
> print('Done.')
>
> **************** dummy.py ***********************************************
>
> ******************************************************************************
> import time
>
> def print1(d):
> for k,v in d.items():
> print(k,v)
>
> def print2(d):
> for key in d:
> print(key)
> def dummy(d):
> start_ = time.time()
> for key in d:
> d[key]=0
> print('Time spent in dummy in seconds: ' + str(time.time()-start_))
>
>
>
>