<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Wrong exit code with mayapy in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8483060#M8536</link>
    <description>&lt;P&gt;Can anyone reproduce this issue? We tested here on multiple machines getting always the same result. I submitted a bug report as well. But no update on that side neither....&lt;/P&gt;</description>
    <pubDate>Fri, 21 Dec 2018 11:19:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-12-21T11:19:51Z</dc:date>
    <item>
      <title>Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8460077#M8535</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With Maya 2018 Update 4 and Update 5, we have a serious issue when importing pymel in a script launched with mayapy. Whenever an exception gets raised during the execution of mayapy, the execution stops and the exception traceback gets printed, but the exit code is always 0! So, our render dispatcher does not recognize anymore when a script failed. You can easily reproduce this under Linux:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#!/usr/bin/env mayapy
raise RuntimeError("test...")
import pymel.core
&lt;/PRE&gt;
&lt;P&gt;Here, the exception gets raised before importing pymel. My exit code is 1, as expected:&lt;/P&gt;
&lt;PRE&gt;[carlo.gi@rd006 ~]$ ./foo
Traceback (most recent call last):
  File "./foo", line 3, in &amp;lt;module&amp;gt;
    raise RuntimeError("test...")
RuntimeError: test...
[carlo.gi@rd006 ~]$ echo $?
1&lt;/PRE&gt;
&lt;P&gt;But when I raise the RuntimeError after the pymel import, like this:&lt;/P&gt;
&lt;PRE&gt;#!/usr/bin/env mayapy
import pymel.core
raise RuntimeError("test...")&lt;/PRE&gt;
&lt;P&gt;Then I get following:&lt;/P&gt;
&lt;PRE&gt;[carlo.gi@rd006 ~]$ ./bar
This plugin does not support createPlatformOpenGLContext!
pymel.core : INFO : Updating pymel with pre-loaded plugins: renderSetup
Warning: file: /opt/grid/software/thirdparty/autodesk/maya/maya-2018.update4/bin/../scripts/startup/initialStartup.mel line 179: Y-axis is already the Up-axis
Traceback (most recent call last):
  File "./bar", line 5, in &amp;lt;module&amp;gt;
    raise RuntimeError("test...")
RuntimeError: test...
[carlo.gi@rd006 ~]$ echo $?
0&lt;/PRE&gt;
&lt;P&gt;We see that Maya gets started and that the error gets raised, but my exit code is 0!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This does not happen with maya.standalone.initialize(). But we need pymel to startup Maya correctly, since the maya.standalone.initialize() does not load modules and plugins correctly (maybe if this could be fixed, we would be happy to not use pymel at all).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This issue also appears only in Update 4 and 5. 3 is running as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you reproduce this issue and hopefully fix this in another Update 6? This is kind of urgent for us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for any help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Greets,&lt;/P&gt;
&lt;P&gt;Carlo&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 14:59:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8460077#M8535</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-11T14:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8483060#M8536</link>
      <description>&lt;P&gt;Can anyone reproduce this issue? We tested here on multiple machines getting always the same result. I submitted a bug report as well. But no update on that side neither....&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 11:19:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8483060#M8536</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-21T11:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8497492#M8537</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is also reported and confirmed by some other users. Do you have a salesforce support case id? I could try to send you the defect id through salesforce.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yours,&lt;/P&gt;
&lt;P&gt;Li&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 07:30:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8497492#M8537</guid>
      <dc:creator>cheng_xi_li</dc:creator>
      <dc:date>2019-01-03T07:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8504199#M8538</link>
      <description>&lt;P&gt;Hi Li!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your reply. I'm not familiar with any support ids. I just sent a request to IT to see if they can provide anything on that matter. Good to know that this is confirmed and hopefully there'll be a fix soon. You think that might be part of another update for Maya 2018?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Greets,&lt;BR /&gt;Carlo&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 08:41:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8504199#M8538</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-01-07T08:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8506738#M8539</link>
      <description>&lt;P&gt;Hi Carlo,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure about that. I had referred this post in our JIRA system so if I've heard something about releasing updates on this issue, I'll let you know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yours,&lt;/P&gt;
&lt;P&gt;Li&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 09:22:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8506738#M8539</guid>
      <dc:creator>cheng_xi_li</dc:creator>
      <dc:date>2019-01-08T09:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8710948#M8540</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just wanted to let you know that this issue is also still present in maya 2019. This issue is preventing us from updating maya. Any news as to when we can expect this to be fixed?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Hans&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2019 16:46:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8710948#M8540</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-05T16:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8713316#M8541</link>
      <description>&lt;P&gt;Hi Hans,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; MAYA_NO_STANDALONE_ATEXIT=1&lt;/PRE&gt;
&lt;P&gt;in environment variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to our engineers, Maya will clean the exit when standalone crashes and make the exit code 0. After setting this value, mayapy should crash without cleaning exit code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yours,&lt;/P&gt;
&lt;P&gt;Li&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 00:29:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8713316#M8541</guid>
      <dc:creator>cheng_xi_li</dc:creator>
      <dc:date>2019-04-08T00:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8717381#M8542</link>
      <description>Thanks, that seems to work.

However, I don't really understand why the decision was made to change that? Basically all render managers rely on the exit code of a process to know if a job succeeded or failed. Why change that behavior (in an update even) which breaks all the job dependencies in a render farm and require to set an environment variable to get everything working as expected again? Also, was this change documented anywhere? 

Actually I would expect the solution to be to set an environment variable when you want to have the new behavior of cleaning the exit code (Although I can't really find a use for that)</description>
      <pubDate>Tue, 09 Apr 2019 12:56:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8717381#M8542</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-09T12:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8757468#M8543</link>
      <description>&lt;P&gt;Wrong exit code (always 0) is also returned by sys.exit() when maya.standalone.uninitialize() is used.&amp;nbsp; Setting the environment variable fixes the behavior.&amp;nbsp; Will this be addressed soon?&amp;nbsp; It's pretty unacceptable to modify the behavior of sys.exit()!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 19:29:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8757468#M8543</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-27T19:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8757580#M8544</link>
      <description>&lt;P&gt;I spoke too soon.&amp;nbsp; In my previous post I said that setting MAYA_NO_STANDALONE_ATEXIT fixes the problem where sys.exit() always returns 0.&amp;nbsp; It doesn't always work.&amp;nbsp; I am calling maya.standalone.uninitialize() to avoid maya crashing on exit.&amp;nbsp; Unfortunately that caused the sys.exit() problem.&amp;nbsp; Now, for a scene that crashes on exit without maya.standalone.uninitialize(),&amp;nbsp; if I use maya.standalone.uninitialize() but also set MAYA_NO_STANDALONE_ATEXIT to keep it from setting the exit code improperly, it starts crashing again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are in the middle of a heavy production schedule and we have no workaround for this problem other than a lot of hand work.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 21:42:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8757580#M8544</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-27T21:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8758681#M8545</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you try to replace sys.exit with os._exit when the environment variable is removed? It could be another workaround.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yours,&lt;/P&gt;
&lt;P&gt;Li&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 05:05:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8758681#M8545</guid>
      <dc:creator>cheng_xi_li</dc:creator>
      <dc:date>2019-04-29T05:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8843422#M8546</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have another case where exiting the job using os._exit(retcode) still returns zero to the operating system.&amp;nbsp; The following is from a gitlab runner cloud execution.&amp;nbsp; The fact that I printed the return code at that point means that just before the os._exit(retcode) the retcode=65280.&amp;nbsp; And the fact that I got 'Job succeeded' means that the operating system read that as a zero return code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Job 10247 abandoned due to job entering killed status&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR: RENDER FAILED?!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RETURN CODE: 65280&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;+ sh&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="term-fg-l-green term-bold"&gt;Job succeeded&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 23:25:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8843422#M8546</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-10T23:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8848748#M8547</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have a reproducible sample? I could send it to our engineers and let them check it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yours,&lt;/P&gt;
&lt;P&gt;Li&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 05:21:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/8848748#M8547</guid>
      <dc:creator>cheng_xi_li</dc:creator>
      <dc:date>2019-06-13T05:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong exit code with mayapy</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/12711676#M8548</link>
      <description>&lt;P&gt;Recently ran into this old issue, it seems to happen to me on macos and linux on maya22 and maya24. Here is my ugly workaround to something that really should be on autodesk to fix.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;_exit_callback_id = None

def add_maya_exit_callback():
    global _exit_callback_id

    def exit_maya(*_, **__):
        os._exit(0)  # noqa

    _exit_callback_id = OpenMaya2.MSceneMessage.addCallback(
        OpenMaya2.MSceneMessage.kMayaExiting, exit_maya
    )

add_maya_exit_callback()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;non-zero exits still work as far as i've tested&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 11:14:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/wrong-exit-code-with-mayapy/m-p/12711676#M8548</guid>
      <dc:creator>MortenBohne</dc:creator>
      <dc:date>2024-04-16T11:14:14Z</dc:date>
    </item>
  </channel>
</rss>

