Hi all,
Before launch the following test.py code you need to create mouse.py and 
then put in same directory the rpyc_classic.py, mouse.py and test.py. 
- the while loop stop when you move mouse at 500px position 
- change the number of process with nb_proc and compare time average to 
compute an HeavyCalc

*problem is: pool mapping do not spawn each console on a different core? 
Thanks for help* 

test.py code: 
================== 

import multiprocessing,subprocess 
import os,signal 
import rpyc,time 

def launch_server(port): 
p=subprocess.Popen("python rpyc_classic.py --host=localhost 
-p"+str(port),shell=False) 
return(p.pid) 

if __name__ == '__main__': 
nb_proc=5 
m=[] 
conn=[0]*nb_proc 
tab=range(500) 
cmds=[2222+i for i in range(nb_proc)] 
pool = multiprocessing.Pool(processes=multiprocessing.cpu_count()) 
async_pool =pool.map_async(launch_server, cmds,callback=m.append) 


for i in range(nb_proc): 
time.sleep(0.1) 
conn[i]=rpyc.classic.connect("localhost",port=2222+i) 
nb=0 
t=time.clock() 
while True: 
x=[] 
y=[] 
for i in range(nb_proc): 
x.append(conn[i].modules.mouse.GetCursorPos()) 
y.append(conn[i].modules.mouse.HeavyCalc(tab)) 
if x[0][0]==500: break 
print 'average time=',t,' (mouse pos)=',x[0][0] 
nb+=1 
t=(time.clock()-t)/nb 


for i in range(nb_proc): 
time.sleep(0.1) 
print "kill ",m[0][i],' ',os.kill(m[0][i],signal.SIGTERM )==None 



mouse.py code: 
============ 

import win32api 

def GetCursorPos(): 
return win32api.GetCursorPos() 
def HeavyCalc(tab): 
return sum(x**x for x in tab) 

Reply via email to