Thanks for sharing Paul.

Mike

From: [email protected] 
[mailto:[email protected]] On Behalf Of Paul Molodowitch
Sent: 09 July 2013 18:29
To: python_inside_maya
Subject: [Maya-Python] In 2014, mayapy errors on exit if sceneAssembly plugin 
loaded

Thought I should let other people know about this, in case they were 
experiencing similar problems: we noticed that, when using 2014's mayapy 
interpreter, it would always segfault when exiting.

We tracked the issue down to a particular plugin, the sceneAssembly plugin. If 
this plugin is not loaded, mayapy will exit cleanly.

We reported this to Autodesk, and they suggested using os._exit... 
unfortunately, this would require us to modify every single mayapy script we 
have (including any "mayapy -c" uses), wrap them to catch SystemExit 
exceptions, and instead us os._exit.  Plus, python would no longer do it's 
normal cleanup (ie, output buffers wouldn't be flushed, and os-level resources 
like file handles might not get released, etc).

So, it seems much easier to just not use sceneAssembly.  The only trick here is 
that simply unloading it won't work - if the plugin was EVER loaded, mayapy 
will still crash on exit - and maya will "by default" set this plugin to 
autoload.

To work around this, you can disable the setting of sceneAssembly to autoload 
for new users by sticking this somewhere in your site's maya startup (mel) code:
    optionVar -iv "oneTimeDefaultPluginLoad2013Update" 1;

For users which already have started 2014 at least once, it will have already 
been set to autoload; so the next time maya starts up, the plugin will load, 
but you can prevent it from loading again by putting in code like this:
    # check for and disable autoload of sceneAssembly plugin - will cause
    # mayapy to exit with an error if loaded... get rid of this if they fix
    # this bug...
    if pm.versions.current() >= pm.versions.v2014:
        def sceneAssemblyDisable():
            if pm.pluginInfo('sceneAssembly', q=1, loaded=1):
                pm.pluginInfo('sceneAssembly', e=1, autoload=False)
        # do this on selection changed, because need a way to delay this
        # so we KNOW it's after the plugins have loaded.  executeDeferred
        # and idleEvent both were too early...
        pm.scriptJob(event=('SelectionChanged', sceneAssemblyDisable), 
runOnce=True)

(The reasoning for this somewhat strange logic is that, when userSetup.py runs, 
autoloaded plugins haven't been loaded yet. This would seem to be ideal, except 
that it seems to only way to turn OFF autoloading is AFTER the plugin has 
actually been loaded.  Nor can you even check to see if it WOULD be autoloaded. 
 So... we need a way to stall until AFTER all auto-loaded plugins have been 
loaded, check if the plugin WAS loaded, and if so, turn off it's autoload from 
then on...)

- Paul
--
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]<mailto:[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to