Cool thanks for the insights! The os._exit(0) was a new one for me. It 
works! No more crashes. Great workaround.

Like Chad said, I learned to add the uninitialize call in 2016 and 
according to the maya documentation this is still valid for 2017. 
I disabled all my startup scripts I think.
I did this by calling these commands before executing the python script:

set MAYA_SCRIPT_PATH=''
set PYTHONPATH=''

Or is there something more that might be needed to be disabled? Is there 
another preferred way to disable the environments that is loading scripts 
and plugins?
If it works for Chad Vernon then there must be something wrong with my 
setup/installation/environment...


Den torsdag 26 januari 2017 kl. 20:24:14 UTC+1 skrev Chad Vernon:
>
> The uninitialize was introduced in 2016 and is required or else Maya 
> crashes on exit...similar to this case!  I'm not sure why this case is 
> crashing.  I tested your script in 2017 and it didn't crash.  Do you have 
> any start up scripts running?  Anything in your MAYA_SCRIPT_PATH env?
>
> On Thursday, January 26, 2017 at 10:34:28 AM UTC-8, Justin Israel wrote:
>>
>> I've never used the uninitialize call. Does it crash when you don't use 
>> that? Does it provide important functionality in a shell script? 
>>
>> I too have seen crashes during exit, and the quick fix can be to use 
>> os._exit(0)
>> This will force the python interpreter to exit quickly without calling 
>> any of the atexit shutdown handlers, which Maya can be using for plugin 
>> unloading and other shutdown operations. If you have done everything you 
>> need to do, closed and flushed all files and output, etc, then you may be 
>> fine with this approach. 
>>
>> Justin 
>>
>>
>> On Fri, Jan 27, 2017, 4:00 AM Robert White <[email protected]> wrote:
>>
>>> I've had the interpreter crash a lot on exit due to plugins not 
>>> unloading cleanly. Might be worth trying it with all of them disabled?
>>>
>>> On Thursday, January 26, 2017 at 5:22:45 AM UTC-6, Erik Karlsson wrote:
>>>>
>>>> Hi everyone!
>>>>
>>>> I'm trying to get maya 2017 up and working. But I'm having some issues.
>>>> This time it's the mayapy.exe. It's not behaving the way it did in 
>>>> 2016. I can't run it cleanly without a crash...
>>>>
>>>> I get a windows popup saying PythonInterpreter has stopped working.
>>>>
>>>> And this is the output from the commandline:
>>>>
>>>> i:\python\scripts>"c:\Program Files\Autodesk\Maya2017\bin\mayapy.exe" 
>>>> testMayaPy.py
>>>> [u'frontShape', u'perspShape', u'sideShape', u'topShape']
>>>> Stack trace:
>>>>   python27.dll!PyInterpreterState_Delete
>>>>   python27.dll!PyGILState_Ensure
>>>>   CommandEngine.dll!TpythonLock::initLock
>>>>   ExtensionLayer.dll!TelfUtils::TelfUtils
>>>>   ExtensionLayer.dll!TscriptAction::~TscriptAction
>>>>   SharedUI.dll!TsetManipValueAction::callContext
>>>>   SharedUI.dll!TelfIconTextButtonCmd::skipFlagForCreateCmd
>>>>   SharedUI.dll!QmayaHotkeyEditor::qt_static_metacall
>>>>   SharedUI.dll!QmayaHotkeyEditor::qt_static_metacall
>>>>   ntdll.dll!RtlDeactivateActivationContextUnsafeFast
>>>>   ntdll.dll!LdrShutdownProcess
>>>>   ntdll.dll!RtlExitUserProcess
>>>>   KERNEL32.DLL!ExitProcess
>>>>   MSVCR110.dll!_initterm_e
>>>>   KERNEL32.DLL!BaseThreadInitThunk
>>>>   ntdll.dll!RtlUserThreadStart
>>>>
>>>>
>>>> the python file "testMayaPy.py" I'm running is simple and looks like 
>>>> this:
>>>>
>>>> import maya.standalone
>>>> maya.standalone.initialize(name='python')
>>>>
>>>> import maya.cmds as cmds
>>>>
>>>> print cmds.ls(type='camera')
>>>>
>>>> maya.standalone.uninitialize()
>>>>
>>>>
>>>> It looks like the script runs fine but has troubles when exiting in 
>>>> 2017.
>>>> In Maya 2016 everything works fine. I get this output:
>>>>
>>>> i:\python\scripts>"c:\Program Files\Autodesk\Maya2016\bin\mayapy.exe" 
>>>> testMayaPy.py
>>>> [u'frontShape', u'perspShape', u'sideShape', u'topShape']
>>>>
>>>>
>>>> Anyone else having similar problems, and possibly a workaround?
>>>>
>>>> The idea is to batchprocess a bunch of maya files. But since I get a 
>>>> crash for every file in the loop, I need to click the annoying 
>>>> "Interpreter 
>>>> has stopped working" window for it to continue. So I managed to process 
>>>> 100 
>>>> maya files with 100 clicks, which is not ideal...
>>>>
>>>> thanks!
>>>> /Erik
>>>>
>>>> -- 
>>> 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/ee83fec9-9835-424e-831e-e31573b01f9e%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/python_inside_maya/ee83fec9-9835-424e-831e-e31573b01f9e%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/9b7f8ace-73cc-4b26-b64c-dfd901b76b23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to