I think I am confusing you all Here is a snippet
http://pastebin.com/J526ftrM I tried my max to explain :) On Fri, Sep 5, 2014 at 4:30 PM, Justin Israel <[email protected]> wrote: > Well 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 > be a pretty crude example: > > #!/usr/bin/env python > import sysimport subprocess > def process(f): > print "process:", f > if __name__ == "__main__": > if '-file' in sys.argv: > process(sys.argv[-1]) > sys.exit() > > for names in ('foo', 'bar', 'baz'): > 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. > > > > On Sat, Sep 6, 2014 at 10:57 AM, Kurian O.S <[email protected]> wrote: > >> Hey 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. >> >> >> On Fri, Sep 5, 2014 at 3:40 PM, Justin Israel <[email protected]> >> wrote: >> >>> Hey 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. >>> >>> >>> >>> >>> On Sat, Sep 6, 2014 at 10:11 AM, Kurian O.S <[email protected]> wrote: >>> >>>> I was wrong its not working :( >>>> >>>> def sig_handler(signum, frame): >>>> pass >>>> >>>> def dosome(args, options): >>>> #here is my seg fault coming >>>> signal.signal(signal.SIGSEGV, sig_handler) >>>> #maya functions goes here >>>> >>>> if __name__ == "__main__": >>>> from multiprocessing import Process, Queue >>>> p = Process(target=dosome, args=(args, options)) >>>> p.start() >>>> p.join() >>>> >>>> This is my code >>>> >>>> >>>> On Fri, Sep 5, 2014 at 11:45 AM, Kurian O.S <[email protected]> wrote: >>>> >>>>> I 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 < >>>>> [email protected]> wrote: >>>>> >>>>>> Hi 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 >>>>>> >>>>>> >>>>>> On 5 September 2014 19:52, Kurian O.S <[email protected]> wrote: >>>>>> >>>>>>> Hey 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 >>>>>>> >>>>>>> def sig_handler(signum, frame): >>>>>>> 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, >>>>>>> send an email to [email protected]. >>>>>>> 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* >>>>>> [email protected] >>>>>> >>>>>> -- >>>>>> 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 [email protected]. >>>>>> 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 >>>> an email to [email protected]. >>>> 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 >>> an email to [email protected]. >>> 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 >> email to [email protected]. >> 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 > email to [email protected]. > 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. > -- --:: 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 email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CANEMyhNSC54ZJbUPv3dL83PsDVTeS8n1VubiNHpmt5kd2oxOvw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
