I am not sure what platform you are running, but on OSX this is even more problematic. It creates orphaned processes that don't close and keep spinning the cpus.
The problem, as I understand it, is that the multiprocessing module needs to be able to fork, copy the memory, and start up the same interpreter again. But Maya is using an embedded python interpreter and it thinks it needs to start up Maya in the new processes, which crashes. On windows, the multiprocessing module has the .set_executable() function: http://docs.python.org/2/library/multiprocessing.html#multiprocessing.set_executable But I don't have windows to test trying to set this to a valid python interpreter, and it is not even platform independent as a solution. What I have gotten to work just fine is the workflow of running your script in a subprocess, and communicating the results back over the pipe. This allows multiprocessing to run under whatever standard python interpreter you want, and is independent of Maya. There are two files here: https://gist.github.com/justinfx/4741527 The first one is a modified version of your original code. The second is the snippet to launch the subprocess from Maya and read the results. -- justin On Feb 8, 2013, at 6:04 AM, Jan: wrote: > 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. > > -- 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.