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 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+unsub...@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.
For more options, visit https://groups.google.com/d/optout.
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 <ruchitinn...@gmail.com> wrote:Hi,I tried multiprocessing module in maya python with basic example and every time it returns new maya instance plusobject 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 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_m...@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.
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_m...@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.
import platform
import multiprocessing
if platform.system() == 'Windows':
multiprocessing.set_executable("C:/Program Files/Autodesk/Maya201x/bin/mayapy.exe")
elif platform.system() == 'Linux':
multiprocessing.set_executable('/usr/Autodesk/maya201x/bin/mayapy')
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/cacf4c80-cacc-4593-857a-509782ba7a87%40googlegroups.com.
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
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_m...@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.
If you don't need to send stdin to your process, no need to create a pipe. And you should use communicate to avoid a deadlock of your child process produces lots of stdout and stderr.