I tried your example & its working fine. Thanks

*In script Editor*
import subprocess
import cPickle

mayapy_path = r'C:/Program Files/Autodesk/Maya201x/bin/mayapy.exe'
script_path = r'E:/multi_test.py'

proc_obj = subprocess.Popen(mayapy_path + ' ' + script_path + ' -po', stdin=
subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = cPickle.load(proc_obj.stdout)
print result

*multi_test.py*
import multiprocessing
from time import time
import cPickle
import sys

## Simple func to eat up cpu power.
def whileFunc(z):
    while z < 100000:
        z += 1 
    return z

if __name__ == "__main__":
    ## Get current time 
    currtime = time()

    ## How often to run (just a test value)
    N = 10000
    ## Just a list with 1s 
    myList = [1]*N

    nrOfProcessors = multiprocessing.cpu_count() 

    ## Set our pool of processors 
    po = multiprocessing.Pool(nrOfProcessors)
    
    ## create the threads 
    res = po.map_async(whileFunc, myList)
    
    ## If we pass a -po flag, pickle the output and write it out    
    if '-po' in sys.argv[1:]:
        results = len(res.get())
        cPickle.dump(results, sys.stdout, -1)
        sys.stdout.flush()
        sys.exit(0)

    print 'This value below should be a 1000:'
    print len(res.get())
    print 'time elapsed:', time() - currtime


-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/2f4122d0-ff64-4ba9-8bfa-71e7bad7f0f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to