On Tue, Jul 17, 2018 at 7:03 PM Marcus Ottosson <konstrukt...@gmail.com>
wrote:

> The Python interpreter and Maya run in the same process, so this is
> expected.
>
> If your multiprocessing doesn't require access to your current session,
> then you may consider instead launching mayapy explicitly (either from or
> outside of Maya), and from there use the multiprocessing module. That
> would create additional instances of mayapy instead which may be what you
> want.
>
> On 17 July 2018 at 07:43, Ruchit Bhatt <ruchitinnewfush...@gmail.com>
> wrote:
>
>> Hi,
>> I tried multiprocessing module in maya python with basic example and
>> every time it returns new maya instance plus
>>
>> object of multiprocessing.Queue() returns nothing on object.get()
>> is python interpreter is not a separate process in Maya ?
>> please share efficient example on how to deal with multiprocessing in Maya.
>> Thank you
>>
>>
You should be able to follow this example:
https://pymotw.com/2/multiprocessing/communication.html#passing-messages-to-processes

The queue has to be passed to the child process as an arg, because it will
be a completely separate process with its own memory.

One other thing to note... be careful when choosing to use multiprocessing
within Maya. Starting a Process() results in a fork of the current Maya
process, which means if you have a huge scene open, you are duplicating
that memory in your child process. It can also result in deadlocks because
of the heavily threaded environment in Maya, and locks that were acquired
may not be released in the new child process (at least this is true on
osx/linux).

If you are set on using multiprocessing, try to create a pool very early
before any memory is allocated in your Maya session. Or better yet, go the
route Marcus suggested and launch a mayapy in a subprocess.

Justin


>
>> --
>> 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/ca05daed-3c24-43de-829c-9ca8aa2f7725%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/ca05daed-3c24-43de-829c-9ca8aa2f7725%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/CAFRtmOCwVF05XD4aYq9Bmr94-jpHmPB526AXLxwb%3D5HwXRgvnQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCwVF05XD4aYq9Bmr94-jpHmPB526AXLxwb%3D5HwXRgvnQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAPGFgA1fWCR%3DiDdqNO3-oE9cghx%3Dk7%3DwHjErnVO0RGD_%2BU3KFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to