Post by Justin IsraelWell if you want to stick with the multiprocessing module and just endure
the possible seg faults and some files not getting processed, you could
print a warning and then do a os._exit(1) to just terminate the process.
Using subprocess, you could have your script take arguments, such as a
-file flag to accept the file to process. When you run it without that
particular flag it would start your batch operation, and then subprocesses
can call the same executable again with specific -file options. Here would
#!/usr/bin/env python
import sysimport subprocess
print "process:", f
process(sys.argv[-1])
sys.exit()
cmd = [sys.argv[0], '-file', names]
# cmd = [sys.executable, sys.argv[0], '-file', names]
subprocess.Popen(cmd)
â
If your script is already executable, then you wouldn't need that
commented line that runs it with "python <script>".
You would want to actually do this in a bounded way, like using a thread
pool or threads+queue to chew on your list of files to process.
Normally the multiprocessing module could work for what you are doing, but
I think it isn't playing nice with Maya's initialized environment when the
process forks.
Post by Kurian O.SHey Guys,
First its a command line tool using optparse to get arguments and options
from user and using maya standalone to do some process ( running through
mayapy ). So Some files its just fail to do the process. Subprocess I am
not sure how I can call a function with arguments.
Post by Justin IsraelHey Kurian,
I'm not clear on this from your code example, but are you using the
multiprocessing module from within Maya? Your example indicates that it is
a standalone script. First, I don't think it is safe to use the
multiprocessing module within Maya, since forking is not a very safe thing
to do in that environment. And second, if you are going to handle the seg
fault yourself, you would be expected to exit the process afterwards (since
you aren't really doing anything to fix the problem), otherwise you are
just going to make it continue having problems.
I think you should go the route that Marcus suggested, where you use
subprocess. This will fork and exec a new process, instead of just forking
your current image, which could lead to tons of problems in Maya.
Post by Kurian O.SI was wrong its not working :(
pass
#here is my seg fault coming
signal.signal(signal.SIGSEGV, sig_handler)
#maya functions goes here
from multiprocessing import Process, Queue
p = Process(target=dosome, args=(args, options))
p.start()
p.join()
This is my code
Post by Kurian O.SI got a hint that I was using signal.signal(signal.SIGSEGV,
sig_handler) in wrong place.
On Fri, Sep 5, 2014 at 11:20 AM, Marcus Ottosson <
Post by Marcus OttossonHi Kurian,
Do you mean you are running separate processes that open up Maya in
the background to do some processing?
Have a look at subprocess.Popen
<https://docs.python.org/2/library/subprocess.html#subprocess.Popen>,
it runs a process completely separate from where you ran it from and
shouldn't be affected by any of them crashing. They can also be run
concurrenctly, by just running many of them at the same time. You'll be
given a handle to the process where you can either communicate or just wait
(join), similar to Process().
Best,
Marcus
Post by Kurian O.SHey Guys,
I have a python script and it will loop through bunch of maya files
and do some stuff. But some time maya get seg fault and my script will stop
there. I tried with signal and multiprocess. But both failed
pass
signal.signal(signal.SIGSEGV, sig_handler)
from multiprocessing import Process, Queue
p = Process(target=startCrawling, args=(args, options))
p.start()
p.join()
Both failed.
Any other method which can trap seg fault and continue with next ?
Thanks
--
--:: Kurian ::--
--
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,
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CANEMyhN3UQnJmc_mWYvQb%3D2B6d6LcNrCmqZ-AaY63DzmG8aSKQ%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CANEMyhN3UQnJmc_mWYvQb%3D2B6d6LcNrCmqZ-AaY63DzmG8aSKQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
*Marcus Ottosson*
--
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,
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODZ1cvY2OFNCF0q6Yg1GMrNd6_y1bcepXF9mZhWkuddgg%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODZ1cvY2OFNCF0q6Yg1GMrNd6_y1bcepXF9mZhWkuddgg%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
--:: Kurian ::--
--
--:: Kurian ::--
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CANEMyhOVgQrUtinX0jWRvdMixb3urCGEtBPtxHW%3DEYe8bed2aw%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CANEMyhOVgQrUtinX0jWRvdMixb3urCGEtBPtxHW%3DEYe8bed2aw%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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0GzFTPT-ED3qKb6j3sutxG4CLp6OPxeN5zcjzeNPk0MQ%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0GzFTPT-ED3qKb6j3sutxG4CLp6OPxeN5zcjzeNPk0MQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
--:: Kurian ::--
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CANEMyhOA8M9mAAzwiQNL-aQHpt9QDYr%3Db3gbyfnXaEakxx1wtA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CANEMyhOA8M9mAAzwiQNL-aQHpt9QDYr%3Db3gbyfnXaEakxx1wtA%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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1ThjyRAjV14NbJwHWWnHwraZNhx%2Bq0Ou-SAh_RCygqtg%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1ThjyRAjV14NbJwHWWnHwraZNhx%2Bq0Ou-SAh_RCygqtg%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.