4
$\begingroup$

I want to run a script in Blender in background mode. If the script fails, I want to print my own error and have Blender exit with a return code of 1. I can do this:

print("script failed", file=sys.stderr)
sys.exit(1)

In older versions of Blender e.g. 2.69, this causes Blender to print stuff like:

Error: Not freed memory blocks: 5
IDProperty group len: 128 0x7f98be0ff938
TEXT_OT_run_script len: 168 0x7f98be064938
wmOperatorPtrRNA len: 24 0x7f98be5f1c18
IDProperty array dup len: 128 0x7f98be16deb8
wmOperatorReportList len: 40 0x7f98be0b1078

Blender quit

In 2.73a, it prints:

Error: Not freed memory blocks: 5

Which is better but not ideal, because it might make it hard for a user of my script to see what the real error is.

Is there a better way to make Blender exit?

$\endgroup$
3
  • 2
    $\begingroup$ maybe it would be easier to just hide the output : see this blender.stackexchange.com/a/28646/5113 $\endgroup$ Commented May 24, 2015 at 10:10
  • $\begingroup$ @Chebhou thanks - good suggestion, but stderr has a special meaning in the environment I'm using: it's for debugging and error messages. I suppose I could wrap the Blender execution in another script that redirects stuff from stderr to stdout... hoping not to though :) $\endgroup$ Commented May 24, 2015 at 11:11
  • $\begingroup$ you don't need to wrap blender execution, in the CMD call you add the redirect command 2>&1 $\endgroup$ Commented May 24, 2015 at 11:40

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.