Just to clarify - this crash isn't caused by pymel - it's caused by the
loading of certain "standard" maya plugins (sceneAssembly and xgen being
two that I know of). The reason why it happens when you import pymel, as
opposed to just maya.standalone.initialize(), is that pymel mimics
"standard" maya startup, and executes (among other things) the user's
prefs/pluginPrefs.mel - that is, it loads all plugins set to autoload.
For instance, if you do this:
import maya.standalone
maya.standalone.initialize()
import maya.cmds as cmds
cmds.loadPlugin('sceneAssembly')
exit()
...then you will get a similar crash on exit. It's a bug that we've
reported several times to Autodesk. There's a sort of workaround in pymel
itself - you can enable it by doing this:
import pymel.core as pm
from pymel.internal.startup import fixMayapy2011SegFault
fixMayapy2011SegFault()
This basically does what Michał Frątczak suggested above, except it
includes some extra stuff that makes it try to detect if there was a
non-zero exit code, and exit using that... so you can still test the return
code from mayapy, and have it be meaningful. It's not bulletproof
though... for instance, if you do:
mayapy -c "import pymel.core as pm; from pymel.internal.startup import
fixMayapy2011SegFault; fixMayapy2011SegFault(); exit(3)"
or even:
mayapy -c "import pymel.core as pm; from pymel.internal.startup import
fixMayapy2011SegFault; fixMayapy2011SegFault(); 1/0"
...it will return non-zero exit codes... but if you do:
mayapy -c "import pymel.core as pm; from pymel.internal.startup import
fixMayapy2011SegFault; fixMayapy2011SegFault(); raise SystemExit(5)"
...it won't.
On Thu, Oct 30, 2014 at 3:15 AM, Michał Frątczak <[email protected]> wrote:
> That works. Thanks !
>
> On Wednesday, October 29, 2014 10:17:49 PM UTC+1, colas wrote:
>>
>> hi,
>> you can use at the end of your script
>>
>> cmds.file(new=True, force=True)
>> os._exit(0)
>>
>> greets,
>> Colas
>>
>>
>> 2014-10-29 11:21 GMT-04:00 Michał Frątczak <[email protected]>:
>>
>>> Hello
>>> mayapy crashes when exiting. this is the script I run:
>>>
>>> import maya.standalone
>>> maya.standalone.initialize(name='python')
>>> from pymel.core import * # this line makes a crash on exit
>>>
>>>
>>> Any info on that? It's hard to use crashing mayapy in batch processing...
>>>
>>> thanks
>>>
>>> --
>>> 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/e95a9edb-463c-425d-89ed-
>>> ffdc10b271a9%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/e95a9edb-463c-425d-89ed-ffdc10b271a9%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/a37035e5-d343-46a9-abba-48e0570045ba%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/a37035e5-d343-46a9-abba-48e0570045ba%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/CAAssL7ZO2Js2nonG40%2B-kvkRVX2T7c2EJAz8OwTvHMcPGziLuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.