Hi,

i'm trying to use the python multiprocessing module to make my script
"multi-threaded".

However every time it tries to start a new process it loads up the "output
window" with command line on how to load the maya batch process.
When I close the window the process closes as well and the function is
never called or it locks up.
Unfortunately I have no idea how I can pass command line info from the
multiprocessing function.

So my question is:
How can I load a multiprocessing process without having the output window
pop up and the process running properly.

Any help would be much appreciated.
(I was thinking of running my code inside of a different interpreter but I
have no idea on how to go at it)


Example function: (it works fine in any other standard python (2.6)
interpreter ).



from multiprocessing import Pool
from time import time

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

## We have to work in __main__ else in some os versions the threads become
unsafe
if __name__ == "__main__":
    ## Get current time
    currtime = time()

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

    nrOfProcessors = 8 #16

    ## Set our pool of processors
    po = Pool(nrOfProcessors)

    ## create the threads
    res = po.map_async(whileFunc, myList)


    print 'This value below should be a 1000:'

    ## The "res.get()" getting of the result actually starts the threads
(surprisingly enough.)
    ## This is also where maya will open up the Output Window and in some
cases lock up.
    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 post to this group, send email to python_inside_maya@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to