mayapy crash on exit when using pymel

602 views
Skip to first unread message

Michał Frątczak

unread,
Oct 29, 2014, 11:21:14 AM10/29/14
to python_in...@googlegroups.com
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

Colas Fiszman

unread,
Oct 29, 2014, 5:17:49 PM10/29/14
to python_in...@googlegroups.com
hi,
you can use at the end of your script

cmds.file(new=True, force=True)
os._exit(0)

greets,
Colas


--
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/e95a9edb-463c-425d-89ed-ffdc10b271a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michał Frątczak

unread,
Oct 30, 2014, 6:15:44 AM10/30/14
to python_in...@googlegroups.com
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 <f.mi...@gmail.com>:
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 python_inside_maya+unsub...@googlegroups.com.

Paul Molodowitch

unread,
Oct 30, 2014, 1:09:03 PM10/30/14
to python_inside_maya
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.

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/a37035e5-d343-46a9-abba-48e0570045ba%40googlegroups.com.

f.michal

unread,
Oct 30, 2014, 1:19:10 PM10/30/14
to python_in...@googlegroups.com
W dniu 2014-10-30 18:08, Paul Molodowitch pisze:
Great answer Paul, thanks. Good to know what's going on...
Reply all
Reply to author
Forward
0 new messages