Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fix multiprocessing support for python

Fix multiprocessing support for python

Currently maya doesn't support the standard python multiprocessing module (on Windows, anyway).  It must be something to to with an interaction between what maya sets for the sys.executable and sys.prefix variables and perhaps the fact that Maya the application won't take a python file as an argument.  The upshot is that you have to do some ugly workarounds like saving temporary files and launching separate Mayapy instances to handle distributed processing.

It'd be really handy for a lot of pipeline work to be able to use vanilla python multiporocessing to paralleliize big tasks.

1 Comment
jonathan_ouellet
Contributor

I second on this.  On windows it would be nice to have something line pythonw.exe but for mayapy.  It is possible to use the multiprocessing module in Maya if you set the executable in the multiprocessing module:

 

import sys
import multiprocessing as mp
from pathlib import Path

if not cmds.about(batch=True):
    path = Path(sys.executable).with_stem("mayapy")
    # set mayapy as process to spawn.
    mp.set_executable(str(path))

for mp.Pool() as pool:
    # do your stuff here.

 

 

This work as expected but it pop up the console. having something like pythonw which doesn't show the console will be really useful on windows.

 

From the python source code. pythonw use `winMain` and compile as a window application:
cpython/PC/python_uwp.cpp at main · python/cpython (github.com)

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea